Formatting Variable Values

You can specify a format for variable values. For example, you can force values to lowercase or uppercase, truncate the length of values, or place values between quotes.

You embed formatting options in variable syntax as follows:

%[[?][-][x][.[-]y][options]:]variable%

The variable formatting options are the following:

Option

Description

?

Mandatory field, if a null value is returned the translate call fails

[-][x].[-]y[M]

Extracts the first y characters or, for -y, the last y characters.

If x is specified, and y is lower than x, then blanks or zeros are added to the right of the extracted characters to fill the width up to x. For -x, the blanks or zeros are added to the left and the output is right-justified.

If the M option is appended, then the first x characters of the variable are discarded and the next y characters are output.

Thus, for an object named abcdefghijklmnopqrstuvwxyz (with parentheses present simply to demonstrate padding):
Template                Output
(%.3:Name%)     gives   (abc)
(%.-3:Name%)    gives   (xyz)
(%10.3:Name%)   gives   (abc       )
(%10.-3:Name%)  gives   (xyz       )
(%-10.3:Name%)  gives   (       abc)
(%-10.-3:Name%) gives   (       xyz)
(%10.3M:Name%)  gives   (jkl)

L[F], U[F], and c

Converts the output to lowercase or uppercase. If F is specified, only the first character is converted. c is equivalent to UF.

q and Q

Surrounds the variable with single or double quotes.

T

Trims leading and trailing whitespace from the variable.

H

Converts number to hexadecimal.

You can combine format codes. For example, the template (%12.3QMFU:Name%) applied to object abcdefghijklmnopqrstuvwxyz generates ("Lmn").