MKD$ function

Purpose: MKD$ converts a double precision number to an 8-byte fixed length string.

Note well that the returned string is stored in binary form which can include embedded zeros. Most BCX string functions and operators can not handle these strings because zero, normally, is used as a terminator to indicate the end of the string.


 Syntax:

 Retstr$ = MKD$(DoubleNum#)

 Parameters:

  • DoubleNum# Double precision number to be converted to an 8-byte fixed length string.

 Return Value:

  • Retstr$, the return value, is an 8-byte fixed length string.

A MKD$ FUNCTION call should not be used as the return value to a string function.


 'WRONG:
 FUNCTION foo$()
  LOCAL D AS DOUBLE
  D# = 555555.5555
  FUNCTION = MKD$(D#)
 END FUNCTION
  
 'CORRECT:
 FUNCTION foo() AS LPSTR
  LOCAL R$
  LOCAL D AS DOUBLE
  D# = 555555.5555
  R$ = MKD$(D#)
  FUNCTION = R
 END FUNCTION

Also note that only single assignments should be performed.


 A$ = MKD$(dbl#)            ' Valid


 A$ = MKD$(dbl#) + "string" ' Not Valid

These limitations are due to the fact that these functions contain binary data. Care should also be taken not to try an reassign a string:


 B$ = A$

would not give the desired result since it would use strcpy.

MKLD$ function

Purpose: MKLD$ converts a long double precision number to an 10-byte fixed length string.

Note well that the returned string is stored in binary form which can include embedded zeros. Most BCX string functions and operators can not handle these strings because zero, normally, is used as a terminator to indicate the end of the string.


 Syntax:

 Retstr$ = MKLD$(LongDoubleNum)

 Parameters:

  • LongDoubleNum Double precision number to be converted to an 10-byte fixed length string.

 Return Value:

  • Retstr$, the return value, is an 10-byte fixed length string.

A MKLD$ FUNCTION call should not be used as the return value to a string function.


 'WRONG:
 FUNCTION foo$()
  LOCAL D AS LONG DOUBLE
  D = 555555.5555
  FUNCTION = MKLD$(D#)
 END FUNCTION
  
 'CORRECT:
 FUNCTION foo() AS LPSTR
  LOCAL R$
  LOCAL D AS LONG DOUBLE
  D = 555555.5555
  R$ = MKLD$(D#)
  FUNCTION = R
 END FUNCTION

Also note that only single assignments should be performed.


 A$ = MKLD$(LongDoubleNum)            ' Valid


 A$ = MKLD$(LongDoubleNum) + "string" ' Not Valid

These limitations are due to the fact that these functions contain binary data. Care should also be taken not to try an reassign a string:


 B$ = A$

would not give the desired result since it would use strcpy.

MKI$ function

Purpose: MKI$ converts a 16-bit(2-byte) SHORT to a 2-byte fixed length string.

Note well that the returned string is stored in binary form which can include embedded zeros. Most BCX string functions and operators can not handle these strings because zero, normally, is used as a terminator to indicate the end of the string.


 Syntax:

 Retstr$ = MKI$(ShortNum)

 Parameters:

  • ShortNum SHORT number to be converted to an 2-byte fixed length string.

 Return Value:

  • Retstr$, the return value, is an 2-byte fixed length string.

A MKI$ FUNCTION call should not be used as the return value to a string function.


 'WRONG:
 FUNCTION foo$()
  LOCAL D AS SHORT
  D = 5555
  FUNCTION = MKI$(D)
 END FUNCTION
  
 'CORRECT:
 FUNCTION foo() AS LPSTR
  LOCAL R$
  LOCAL D AS SHORT
  D = 5555
  R$ = MKI$(D)
  FUNCTION = R
 END FUNCTION

Also note that only single assignments should be performed.


 A$ = MKI$(ShortNum)            ' Valid


 A$ = MKI$(ShortNum) + "string" ' Not Valid

These limitations are due to the fact that these functions contain binary data. Care should also be taken not to try an reassign a string:


 B$ = A$

would not give the desired result since it would use strcpy.

MKL$ function

Purpose: MKL$ converts an integer to an 4-byte fixed length string.

Note well that the returned string is stored in binary form which can include embedded zeros. Most BCX string functions and operators can not handle these strings because zero, normally, is used as a terminator to indicate the end of the string.


 Syntax:

 Retstr$ = MKL$(IntNum%)

 Parameters:

  • IntNum% integer number to be converted to an 4-byte fixed length string.

 Return Value:

  • Retstr$, the return value, is an 4-byte fixed length string.

A MKL$ FUNCTION call should not be used as the return value to a string function.


 'WRONG:
 FUNCTION foo$()
  LOCAL D%
  D% = 555555
  FUNCTION = MKL$(D%)
 END FUNCTION
  
 'CORRECT:
 FUNCTION foo() AS LPSTR
  LOCAL R$
  LOCAL D%
  D% = 555555
  R$ = MKL$(D%)
  FUNCTION = R
 END FUNCTION

Also note that only single assignments should be performed.


 A$ = MKL$(LongNum)            ' Valid


 A$ = MKL$(LongNum) + "string" ' Not Valid

These limitations are due to the fact that these functions contain binary data. Care should also be taken not to try an reassign a string:


 B$ = A$

would not give the desired result since it would use strcpy.

MKS$ function

Purpose: MKS$ converts a single precision number to an 4-byte fixed length string.

Note well that the returned string is stored in binary form which can include embedded zeros. Most BCX string functions and operators can not handle these strings because zero, normally, is used as a terminator to indicate the end of the string.


 Syntax:

 Retstr$ = MKS$(Single!)

 Parameters:

  • Single! Single precision number to be converted to a 4-byte fixed length string.

 Return Value:

  • Retstr$, the return value, is an 4-byte fixed length string.

A MKS$ FUNCTION call should not be used as the return value to a string function.


 'WRONG:
 FUNCTION foo$()
  LOCAL D AS SINGLE
  D! = 55.5555
  FUNCTION = MKS$(D!)
 END FUNCTION
   
 'CORRECT:
 FUNCTION foo() AS LPSTR
  LOCAL R$
  LOCAL D AS SINGLE
  D! = 55.5555
  R$ = MKS$(D!)
  FUNCTION = R
 END FUNCTION

Also note that only single assignments should be performed.


 A$ = MKS$(FloatNum!)            ' Valid


 A$ = MKS$(FloatNum!) + "string" ' Not Valid

These limitations are due to the fact that these functions contain binary data. Care should also be taken not to try an reassign a string:


 B$ = A$

would not give the desired result since it would use strcpy.

CVD function

Purpose: CVD converts a MKD$ format 8-byte fixed length string to a double precision number.


 Syntax:

 Retval# = CVD(MKDString$)

 Parameters:

  • MKDString$ MKD$ format 8-byte fixed length string to be converted to a double precision number.

 Return Value:

  • Retval#, the return value, is a double precision number.

CVLD function

Purpose: CVLD converts a MKD$ format 10-byte fixed length string to a long double precision number.


 Syntax:

 Retval# = CVLD(MKLDString$)

 Parameters:

  • MKDString$ MKLD$ format 10-byte fixed length string to be converted to a long double precision number.

 Return Value:

  • Retval#, the return value, is a double precision number.

CVI function

Purpose: CVI converts an MKI$ format 2-byte fixed length string to a 16-bit(2-byte) SHORT number.


 Syntax:

 Retval% = CVI(MKIString$)

 Parameters:

  • MKIString$ MKI$ format 2-byte fixed length string to be converted to 16-bit(2-byte) SHORT number.

 Return Value:

  • Retval%, the return value, is a 16-bit(2-byte) SHORT number.

CVL function

Purpose: CVL converts an MKL$ format 4-byte fixed length string to a long integer number.


 Syntax:

 Retval% = CVL(MKLString$)

 Parameters:

  • MKLString$ MKL$ format 4-byte fixed length string to be converted to a 32-bit(4-byte) LONG number.

 Return Value:

  • Retval%, the return value, is a 32-bit(4-byte) LONG number.

CVS function

Purpose: CVS converts an MKS$ format 4-byte fixed length string to a single precision number.


 Syntax:

 Retval! = CVS(MKSString$)

 Parameters:

  • MKSString$ MKS$ format 4-byte fixed length string to be converted to a single precision number.

 Return Value:

  • Retval!, the return value, is a single precision number.

Example:


 DIM int1%
 DIM str1$
 DIM str2$
 DIM sng1!
 DIM sng2!
 DIM dbl1#
 DIM dbl2#

 str1$ = "AB"
 int1% = CVI(str1$)
 PRINT int1%
 str2$ = MKI$(int1%)
 PRINT str2$

 str1$ = "ABCD"
 int1% = CVL(str1$)
 PRINT int1%
 str2$ = MKL$(int1%)
 PRINT str2$

 sng1! = 1.23456
 str1$ = MKS$(sng1!)
 PRINT str1$
 sng2! = CVS(str1$)
 PRINT sng2!

 dbl1# = 1.23456789012345
 str1$ = MKD$(dbl1#)
 PRINT str1$
 dbl2# = CVD(str1$)
 PRINT dbl2#

Result:


  16961
 AB
  1145258561
 ABCD
 ž?
  1.23456
 ÝYŒBÊÀó?
  1.23456789012345