Fmt function

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.

ParameterDescription
StringAny character string to format on output.
FormatAn 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.

Justification

All formats must specify one of the following justifications.

CodeResult
LLeft justification.
RRight justification.
CCenter justification.
TText justification: left justify and insert text marks (ASCII character 251) as line delimiters.

fill_char

Contains a single character, enclosed by parentheses, that replaces the leading or trailing blank spaces. The default fill character is a space.

field_size

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.

Mask

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.

Conversion

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"
  • guides/programming/programmers_reference_manual/fmt.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1