Description:
Translates characters in the source string according to the From and To string and put them into the Result Field.
RPG Style Fixed Format:
|
Op Code: |
Factor 1: |
Factor 2: |
Result Field: |
Indicators: |
|
XLATE (E P) |
From:To |
String:Start |
Target String |
__ ER __ |
Free Format:
XLATE
MAPFROM (Character Expression)
MAPTO (Character Expression)
BASESTR (Character Expression)
STARTPOS (Numeric Expression | 1
)
TARGET (Character Expression)
FILL (*NOPAD
| *PAD)
ERR (Indicator Variable | *Extended)
TYPE (*None
| *Char | *Packed | *Zoned)
LEN (Length Integer, [Decimal Integer])
Comments:
XLATE starts translating the source at the location specified in Factor 2 and continues character by character, from left to right. If a character of the source string exists in the From string, the corresponding character in the To string is placed in the result field. Any characters in the source field before the starting position are placed unchanged in the Result Field.
Required Parameters:
The MAPFROM parameter (Factor 1) is required and must contain the From string, followed by a colon, followed by the To string (MAPTO). If a character in the From String is duplicated, the first occurrence is used.
The BASESTR parameter (Factor 2) is required and must contain either the source string or the source string followed by a colon and the start location (STARTPOS).
The TARGET parameter (Result Field) is required and contains the target string.
Optional Parameters:
The FILL parameter specifies if you want to fill, or pad the TARGET (Result Field) with blanks. The default is *NOPAD.
*NOPAD indicates that the Result Field will not be padded with blanks.
*PAD indicates that the Result Field will be padded with blanks.
The ERR parameter determines what the runtime will do if an error occurs while executing this command. The following rules apply:
ERR (Indicator Variable) - The specified Indicator is set if an error occurred.
ERR(*EXTENDED) - A program status flag is set whose status can be checked using the %ERROR built-in function. This is equivalent to coding the E extender in RPG Fixed Format (OPCODE(E)).
If the ERR keyword is not given and an error occurs, a runtime exception will be thrown, terminating the program.
The TYPE parameter can be any of the Types listed (Character, Packed or Zoned). *NONE is the default. See Type Parameter for further information.
The LEN parameter defines the length of the field. If LEN is decimal (3,1) *ZONED is assigned as the default. If LEN is character (3), *CHAR is assigned as the default.
Depending upon the Type specified, the LEN parameter may be required. For instance, TYPES of *CHAR, *PACKED, *ZONED will require a LEN. A compiler message will display if the LEN parameter is needed.