Caché MultiValue Basic Reference
FMTS
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Formats each element of a dynamic array for display.
Synopsis
FMTS(dynarray,format)
Arguments
dynarray An expression that resolves to a dynamic array to be formatted for display.
format An expression that resolves to a string consisting of positional letter and number codes specifying the display format for the elements of dynarray.
Description
The FMTS 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.
The format string has the following format:
wfRn
w 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.
f 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.
R 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.
n 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:
For further details on format codes, refer to the FMT function.
Examples
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:
nums="1.2":@VM:"2.45":@VM:"3":@VM:"4.123456":@VM:"0"
PRINT FMTS(nums,"R4")
    ! 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:
flints="FRED":@VM:"BARNEY":@VM:"WILMA":@VM:"PEBBLES"
PRINT FMTS(flints,"7^L")
    ! Returns: FRED^^^ýBARNEY^ýWILMA^^ýPEBBLES
PRINT FMTS(flints,"7^R")
    ! Returns: ^^^FREDý^BARNEYý^^WILMAýPEBBLES
See Also