Formats each element of a dynamic array for display.
||An expression that resolves to a dynamic array to be formatted for display.
||An expression that resolves to a string consisting of positional letter and number codes specifying the display format for the elements of dynarray.
function returns the dynarray
value with each element formatted as specified by format
. This formatting may include justification, character filling, and the rounding or zero padding of numeric element values. The most common use for FMTS
is to provide a uniform display format for fractional numbers.
string has the following format:
||Optional The overall width of the display field, specified as a positive integer. Used to impose a uniform width (number of characters) for each element of dynarray. Different operations are performed if w is larger or smaller than the length of an element, as described in the FMT function.
||Optional A fill character, specified as a single character. If the fill character is a number, the backslash (\), or the letters L, R, or T it must be enclosed in string delimiter quotes. You must specify w to use f. If you specify w, but do not specify f, it defaults to the space character.
||Optional The letter R or L specifying right or left justification. This letter code is not case-sensitive. If you do not specify a letter code, FMTS defaults to left justification.
||Optional The number of fractional digits to the right of the decimal place, specified as a positive integer. If you specify n, it must either be the only code in format, or it must be preceded by the letter R or L. If you do not specify n, FMTS defaults to number of fractional digits in string.
There are two basic uses of format
To return fractional numbers in a standard form. FMTS
can be used to round a fractional number to an integer or to a specified number of fractional digits. If the specified number of fractional digits is larger than the number of fractional digits in the element value, FMTS
zero pads the additional digits.
To return strings in a standard form. FMTS
can left justify or right justify a string and add a fill character before or after to make each element contain the same number of characters.
For further details on format
codes, refer to the FMT
The following example uses Rn formatting to format the elements of a dynamic array so that all elements display 4 decimal digits. Note that both zero padding and rounding are performed as needed:
! Returns: 1.2000ý2.4500ý3.0000ý4.1235ý0.0000
The following example uses wfL formatting to format the elements of a dynamic array so that all elements display seven characters. Note that the ^ character is used as the fill character:
! Returns: FRED^^^ýBARNEY^ýWILMA^^ýPEBBLES
! Returns: ^^^FREDý^BARNEYý^^WILMAýPEBBLES
© 1997-2019 InterSystems Corporation, Cambridge, MA