Format
String Function
The Format function converts a number to a string in the specified scheme. Primarily, use Format with the concatenation operator ("$") and another string. Format is often used in conjunction with the Xwrite statement to produce formatted output.
Syntax
Format(<expression>, <total number of characters in expression> {,<digits after decimal>})
Examples
Display "The value of Var1 is" $ Format(Var1, 5)
The following logic shows formatted output when an Entity arrives at the Truck Location.
Display "The variable Var1 is" $ Format(Var1,5,2)
In this example, if the value of Var1 is 378.87654, it is written to the file as:
The variable Var1 is 378.88
Parameters
<expression>
The expression to be evaluated and converted into a string. If the expression results in an integer, it is converted to a real number.
<total number of characters in expression>
Formats the number so that it occupies a total space equal to the number of digits before + number of digits after the decimal + one character for the decimal point. For example, if you were to write the following logic:
Xwrite file1 Format (10.0 4 1) Xwrite file1 Format (1.0 4 1)
...the file shows 10.0 1.0 with a space before the 1.0.
{,<digits after decimal>}
An expression that evaluates to the maximum number of digits to the right of the decimal. If there are more digits to the right of the decimal than this number, ProModel truncates the excess digits. If there are fewer digits, ProModel pads the number with zeros.