CAST converts a variable from one data type to another.
Syntax:NewObject = CAST(DataType, Object) Return Value:
Parameters:
|
UNION MyUnion MyInt AS DOUBLE MyChar AS UCHAR END UNION DIM Example AS MyUnion DIM longvar AS LONG Example.MyChar = 255 'longvar = (LONG) Example ' This statement will -NOT- compile with any compiler. longvar = (LONG) Example.MyChar ' This statement WILL compile with any C/C++ compiler. longvar = CAST(LONG, Example.MyChar) ' This statement WILL also compile, using the CAST macro. PRINT longvar ' Should PRINT 255 PAUSE
MKD$ converts a DOUBLE precision number to an 8-byte fixed length string.
Syntax:Retstr = MKD$(DoubleNum AS DOUBLE) Return Value:
Parameters:
|
π The returned string is stored in binary form which can include embedded zeros. Most BCX string functions and operators cannot handle these strings because zero, normally, is used as a terminator to indicate the end of the 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. Also, be careful not to reassign a string:
B$ = A$
would not give the desired result since it would use strcpy.
MKLD$ converts an LDOUBLE precision number to an 10-byte fixed length string.
Syntax:Retstr = MKLD$(LongDoubleNum AS LDOUBLE) Return Value:
Parameters:
|
π The returned string is stored in binary form which can include embedded zeros. Most BCX string functions and operators cannot handle these strings because zero, normally, is used as a terminator to indicate the end of the string.
A MKLD$ function call should not be used as the return value to a string function.
'WRONG: FUNCTION foo$ () LOCAL D AS LDOUBLE D = 555555.5555 FUNCTION = MKLD$(D#) END FUNCTION 'CORRECT: FUNCTION foo () AS LPSTR LOCAL R$ LOCAL D AS LDOUBLE 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. Also, be careful not to reassign a string:
B$ = A$
would not give the desired result since it would use strcpy.
MKI$ converts a 16-bit (2-byte) SHORT to a 2-byte fixed length string.
Syntax:Retstr = MKI$(ShortNum AS SHORT) Return Value:
Parameters:
|
π The returned string is stored in binary form which can include embedded zeros. Most BCX string functions and operators cannot handle these strings because zero, normally, is used as a terminator to indicate the end of the 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. Also, be careful not to reassign a string:
B$ = A$
would not give the desired result since it would use strcpy.
MKL$ converts an INTEGER to an 4-byte fixed length string.
Syntax:Retstr = MKL$(IntNum AS INTEGER) Return Value:
Parameters:
|
π The returned string is stored in binary form which can include embedded zeros. Most BCX string functions and operators cannot handle these strings because zero, normally, is used as a terminator to indicate the end of the 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$(IntNum) ' Valid
A$ = MKL$(IntNum) + "string" ' Not Valid
These limitations are due to the fact that these functions contain binary data. Also, be careful not to reassign a string:
B$ = A$
would not give the desired result since it would use strcpy.
MKS$ converts a SINGLE precision number to an 4-byte fixed length string.
Syntax:Retstr = MKS$(Single AS SINGLE) Return Value:
Parameters:
|
π The returned string is stored in binary form which can include embedded zeros. Most BCX string functions and operators cannot handle these strings because zero, normally, is used as a terminator to indicate the end of the 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. Also, be careful not to reassign a string:
B$ = A$
would not give the desired result since it would use strcpy.
CVD converts a MKD$ format 8-byte fixed length string to a DOUBLE precision number.
Syntax:Retval = CVD(MKDString AS STRING) Return Value:
Parameters: |
CVLD converts a MKLD$ format 10-byte fixed length string to an LDOUBLE precision number.
Syntax:Retval = CVLD(MKLDString AS STRING) Return Value:
Parameters: |
CVI converts an MKI$ format 2-byte fixed length string to a 16-bit(2-byte) SHORT number.
Syntax:Retval = CVI(MKIString AS STRING) Return Value:Parameters: |
CVL converts an MKL$ format 4-byte fixed length string to a LONG integer number.
Syntax:Retval = CVL(MKLString AS STRING) Return Value:
Parameters: |
CVS converts an MKS$ format 4-byte fixed length string to a SINGLE precision number.
Syntax:Retval = CVS(MKSString AS STRING) Return Value:
Parameters: |
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#
16961 AB 1145258561 ABCD ΕΎ? 1.23456 ΓYΕBΓΓΓ³? 1.23456789012345