FORMAT
Script Function: Changes the formatting of a number.
Syntax
FORMAT (Number [,Format])
Syntax 
Description/Format 

Number 
Number that should be formatted. 
Format 
Zeros that serve as placeholders for the number of digits. In floatingpoint numbers, you can also specify a delimiter as the decimal point and the number of positions after the decimal point.

Return codes 

Number without leading zeros. 
Comments
This script function can be used to add or remove leading zeros to or from a number. In floatingpoint numbers, you can also specify the number of positions that should be used after the decimal point. You can do so by defining a decimal point as the delimiter in the Format parameter. The zeros that you enter after the delimiter represent the number of decimal places. Numbers that exceed the specified number are truncated. The results are not rounded. If you do not specify a decimal point, all decimal numbers are removed. If the number includes fewer decimal places than is specifies in Format, the rest is filled with zeros.
The number of leading zeros of integers can also be specified in the Format parameter. The number of zeros given in this parameter serve as placeholders for the total number of digits. If you use fewer digits than is specified, the value remains unchanged. The leading zeros are removed if you do not use this parameter.
If you also specify the character '+' as the first character in Format (such as "+0.00", this algebraic sign is also displayed in positive numbers.
The target variable to which this function's return code is assigned must be of data type " string ".
If the result is zero because all decimal positions have been removed, the algebraic sign is irrelevant and is removed.
Examples
The first example deletes the leading zeros from the script function's 16digit return code. The result is output in the activation protocol.
:SET &SRV#=SYS_BUSY_60()
:SET &RET#=FORMAT(&SRV#)
:PRINT &RET#
The second example formats the specified number to 5 digits. The result (00125) is output in the activation protocol.
:SET &RET#=FORMAT("125","00000")
:PRINT &RET#
The leading zeros are also deleted in the third example because the number of specified digits was incorrect (too few). The result (333) is output in the activation protocol.
:SET &RET#=FORMAT("0000333","00")
:PRINT &RET#
In the fourth example, the number does not change.
:SET &RET#=FORMAT("555","00")
:PRINT &RET#
The fifth example shows the formatting of a floatingpoint number to one position after the decimal point. "0.7" is output in the activation protocol.
:DEFINE &NUM#,float
:DEFINE &RET#,string
:SET &NUM#=0.75
:SET &RET#=FORMAT(&NUM#,"00.0")
:PRINT &RET#
Decimal places are removed in the sixth example. The output in the activation report is "0000".
:DEFINE &NUM#,float
:DEFINE &RET#,string
:SET &NUM#=0.65
:SET &RET#=FORMAT(&NUM#,"0000")
:PRINT &RET#
See also:
Script element  Description 

Deletes empty spaces at the beginning of a string.  
Deletes the empty spaces at the end of string. 
About Scripts
Script Elements  Alphabetical Listing
Script Elements  Ordered by Function