Formats data in a specified pattern. The pattern can include field width, background fill characters, line justification, conversion specifications, and masking.
output = Fmt(string, format)
The Fmt function has the following parameters.
Parameter | Description |
---|---|
String | Any character string to format on output. |
Format | An argument for format might be structured as follows. justification[(fill_char)]mask justification[(fill_char)]#[field_size] conversion Note: The # character is essential, if you are going to specify field size. |
All formats must specify one of the following justifications.
Code | Result |
---|---|
L | Left justification. |
R | Right justification. |
C | Center justification. |
T | Text justification: left justify and insert text marks (ASCII character 251) as line delimiters. |
Contains a single character, enclosed by parentheses, that replaces the leading or trailing blank spaces. The default fill character is a space.
An optional parameter. Specifies the size of the field in which the value is to be justified. It must yield a positive integer. If the output data has a length larger than field_size, it will be truncated, unless T is chosen for justification.
The template of the desired output. For example, ###-##-### would be the template or mask that could be used for a variable that will be output as a Social Security number. The "#" characters are replaced with the characters from the variable, while the "-" characters are placed into the output according to the mask pattern.
Standard output conversions can be specified. (Refer to the OConv function.)
FMT is identical to OConv().
The following examples show how to use Fmt for format report output.
Output Fmt("12345","L#6") "12345 " Fmt("12345","R(*)#8") "***12345" Fmt("ABCDEFG","R#4") "DEFG" Fmt('ABCD','C#6') " ABCD " Fmt(6666,"D2-") "04-01-86" Fmt("1234567890","L(###)###-####")"(123)456-7890"