NET/MASTER Network Control Language (NCL) Reference Manual
TRANSLATE
Built-in Functions
4–86 106126 Tandem Computers Incorporated
TRANSLATE The TRANSLATE built-in function translates all or part of a specified string, according
to input and output translation tables. TRANSLATE performs arbitrary substitution
of characters in a string, as well as changing specified characters in a string from
lowercase to uppercase, or from a hexadecimal value to an alternative character value.
TRANSLATE(
string
[, [
tableo
] [, [
tablei
] [,
pad
] ] ] )
string
specifies the input string, which may be of any length.
tableo
specifies the output table to be used. If the table is not the same length as
tablei
,
it is padded with the specified pad character or truncated to the same length.
Duplicate characters in this table allow several input characters to map to the same
output character. If this operand is omitted, the result is a table of pad characters
the same length as
tablei
.
tablei
specifies the input table to be used.
tablei
defines the characters that are
affected by the translation. If duplicate characters occur, the first occurrence is
used. If this operand is omitted, a default table of XRANGE ('00'x to 'FF'x) is used.
See the XRANGE built-in function later in this section for more information on
how this default table is set.
pad
specifies the character to be used to lengthen
tableo
to the same length as
tablei
, if required. The default pad character is a space.
Considerations
The action performed depends on the parameters specified. If only
string
is
provided, lowercase characters in the native (ASCII) character set are translated to
uppercase. Other characters are not changed. In all other cases,
tableo
and
tablei
define a translation rule as follows:
Each input character is located in
tablei
.
The index value of this character in
tablei
is used to index
tableo
. The
character at this position replaces the source character in the string.
If both
tablei
and
tableo
are omitted, the input string is translated to a string
of the same length, consisting of the specified pad character (or spaces). This is not
the same as specifying only one parameter (for example, the string), which causes
an uppercase table to be used.