Format

(Engine-Level Function)

Description: Returns a text string corresponding to numbers in a specified format.
Returns: Text
Usage: Script or steady state.
Function Groups: String and Buffer
Related to: BuffWrite | CommaFormat | FWrite | Output | Print | PrintLine
Format: Format(Width, Precision, Value)
Parameters:  
Width
Required. Any numeric expression giving the minimum number of characters to use. If fewer characters are required to produce the output, the area is filled with blank spaces on the left to make up the required number of characters. This is useful for aligning numbers on the right.

If more characters are required than the Width parameter specifies, the extra characters are extended to the right. By making Width 0, the output will be aligned on the left.

If the Width parameter is greater than or equal to 100, the format of the floating point number used is in the most compact form which may be in exponential form if the exponent is less than -4 or is greater than the specified Precision parameter.

The actual width used in this mode is 100 less than the specified Width. Trailing 0s are not displayed in this mode. Values for Width outside the range of 0 to 255 inclusive are invalid.
Precision  
Required. Any numeric expression giving the precision of the output (with rounding). It gives the number of digits to appear after the decimal point, if Width is less than 100, or the maximum number of significant digits to appear, if Width is greater than or equal to 100.

Values for Precision outside the range of 0 to 255 inclusive are invalid.
Value  
Required. Any numeric parameter giving the number to be formatted.
Comments: This function is useful in conjunction with the Print statement to produce numbers in a printed report. Note that if a text expression is expected as an argument by any VTScada function, and a numeric argument is used, VTScada performs an automatic Format on the value.

Example:

  Number = 123.5692;
  TextVal = Format(7 { Minimum number of characters },
                   2 { Number of digits after decimal point }, 
                   Number); 

The variable TextVal will be equal to " 123.57"