Function Str() Foundation
Converts the value of a numeric expression to a character string.
Str( <nValue>, [<nLength>], [<nDecimals>] ) --> cString
The function Str() formats a numeric value <nValue> as a character string. The length of the character string returned from Str() depends on the optional arguments <nLength> and <nDecimals>. When neither of the arguments are included, the numeric value is formatted according to the following rules:
Numeric expression | Length of the return character string |
---|---|
Expressions/Constants | At least ten digits plus decimal places |
Field variable | Field length including decimal places |
Month()/Day() | 3 digits |
RecNo() | 7 digits |
Val() | At least 3 digits |
Year() | 5 digits |
The conversion function Str() converts a numeric value to a character string. It resembles the function Transform() which converts a value to a character string according to a given formatting mask. Str() works according to firm rules and only converts numeric values to character strings. Str() is frequently used when numeric values are output or when a character value and a numeric value must be combined in an index expression.
Str() formats numeric values and depends on the optional arguments <nLength> and <nDecimals>. The numeric value is rounded when <nDecimals> is less than the number of decimal places in <nValue>. The default value for <nDecimals> is zero. This means that if this argument is missing, <nValue> is first rounded to an integer and then changed to a character string. When the value for <nLength> is smaller than the number of places in front of the decimal point of <nValue>, Str() returns asterisks (*) in place of digits (as with a numeric overflow).
Val() is the reverse of the function Str() and converts a character string to a numeric value.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.