Official Content

Converts a numeric expression into a string.

Syntax

Str(Value [ , Length [ , Decimals ] ] )

Where:

Value
   Is the Numeric expression to be converted into a string.

Length
   Is a Numeric expression that indicates the total length of the Value parameter, including numeric sign and decimal point. If you don't complete this parameter, the default value is 10.
 
Decimals
   Is a Numeric expression that indicates the number of decimal places you want to convert. If you don't complete this parameter, the default value is 0.

Type Returned:
Character

Scope

Objects: Procedure, Transaction, Web Panel, Panel

Description

Returns a character string, aligned to the right, which represents the Value in string format.

If you specify fewer decimal places (Decimal parameter) than those in the Value parameter, the value is rounded. 

Constraints:
0 <= Length <= 18

In COBOL the limit for Decimals is 2.

Note: Insignificant zeros are truncated.

Samples

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.4 is rounded and the decimal is discarded because it ends up having a zero value.

See Also

Concat function
Substr function
Val function

Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant