Number/character conversion functions
 
Function
Description
Custom or in VFP subset?
CHR(INTEGER_VALUE)
 
This function returns the character whose numeric ASCII code is identical to the given integer. The integer must be between 0 and 255.
VFP subset
STR(NUMBER, LENGTH, DECIMALS)
 
The string function converts a numeric value into a character value. LENGTH is the number of characters in the new string, including the decimal point. DECIMALS is the number of decimal places desired. The parameters LENGTH and DECIMALS must be constant. If the number is too big for the allotted space, *’s are returned.
VFP subset
VAL(CHAR_VALUE)
 
The value function converts a character value to a numeric value.
VFP subset
 
Examples:
CHR(65) returns A.
STR( 5.7, 4, 2) returns 5.70
The number 5.7 is converted to a string of length 4. In addition, there are two decimal places.
STR( 5.7, 3, 2) returns ***
The number 5.7 cannot fit into a string of length 3 if it is to have two decimal places. Consequently, *’s are filled in.
VAL( '10' ) returns 10.
VAL( '-8.7' ) returns -8.7.