To convert a numeric expression into a string.
Syntax
Str( n_{1} [ , n_{2} [ , n_{3} ] ] )
Type Returned
Character
Where:
n_{1}
Is the numeric expression to be converted into a string.
n_{2}
Numeric expression. It is the total length of n_{1}, including numeric sign and decimal point.
n_{3}
Numeric expression. It is the number of decimal places
Description
Returns a character string, aligned to the right, which represents n_{1} in string format. If you specify fewer decimal places than those in the numeric expression n_{1}, the value is rounded.
Constraints:
0 <= n_{2} <= 18
In Visual FoxPro the limit for n_{3} is: 18 minus one place for the sign, and minus the decimal places. In other words, a limit of 18 places for the whole numeric expression.
In COBOL the limit for n_{3} is 2.
Note
Insignificant zeros are truncated.
10 = Default value for n_{2}
0 = Default value for n_{3}
Examples
Str(1.25) = " 1"
Note the blank spaces due to the right alignment.
Str(1.25,10,2) = " 1.25"
Note the blank spaces due to the right alignment.
Str(1.25,2,1) = "1"
Str(1.25,5,1) = " 1.3"
Note the blank space due to the right alignment.
Str(1.25,5,2) = "1.25"
Str(12345678901234.12,13,2) = "*************"
Str(1234.4,5,1) = "1234"
Here 1234.5 is rounded and the decimal is discarded because it ends up having a zero value.
Scope
Objects Procedure object, Transaction object, Web Panel object
See also
Concat function
Substr Function
Val function
