Click or drag to resize

Str3 Function

X#
Convert a numeric expression to a string of specific length and decimal places.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION Str3(
	fNumber AS FLOAT,
	dwLength AS DWORD,
	dwDecimals AS DWORD
) AS STRING
Request Example View Source

Parameters

fNumber
Type: Float
The numeric expression to convert.
dwLength
Type: DWord
The length of the string to return, including decimal digits, decimal point, and sign.
If dwLength is not long enough to hold the entire number, the result will be in scientific notation.
dwDecimals
Type: DWord
The number of decimal places to return.

Return Value

Type: String
Remarks
Str3() is a typed version of the Str() numeric function where all three arguments are mandatory. See Str() for a detailed description.
Examples
These examples show how to use Str3() to change a number to a string:
X#
1LOCAL fNumber AS FLOAT
2fNumber := 123.45
3? Str3(fNumber, 10, 1)            //      123.5
4? Str3(fNumber * 10, 7, 2)        // 1234.50
5? Str3(fNumber * 10, 12, 4)        //    1234.5000
This functions returns a string of all asterisks when the Decimals parameter is > 0 and the Decimals parameter is > Length-2. Also a string of all asterisks is returned when the number does NOT fit into the allocated space. Example:
X#
1? Str(9,6,6)    => "******"
2? Str(9,6,5)    => "******"
3? Str(9,6,4)    => "9.0000"
4? Str(9,6,3)    => " 9.000"
5? Str(10,6,6)    => "******"
6? Str(10,6,5)    => "******"
7? Str(10,6,4)    => "******"
8? Str(10,6,3)    => "10.000"
See Also