Description

Formats data in a specified pattern. The pattern can include field width, background fill characters, line justification, conversion specifications, and masking.

Syntax

output = Fmt (string, format)

Parameters

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.
field_sizeAn 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.
MaskThe 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.
fill_charContains a single character, enclosed by parentheses, that replaces the leading or trailing blank spaces. The default fill character is a space.
ConversionStandard output conversions can be specified. (Refer to the OConv function.)

FMT is identical to OConv().

Example

The following examples show how to use Fmt for format report output.

Example 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"
  • No labels