%XLATE (Translate)

%XLATE(from:to:string{:startpos})

%XLATE translates string according to the values of from, to, and startpos.

The first parameter contains a list of characters that should be replaced, and the second parameter contains their replacements. For example, if the string contains the third character in from, every occurrence of that character is replaced with the third character in to.

The third parameter is the string to be translated. The fourth parameter is the starting position for translation. By default, translation starts at position 1.

If the first parameter is longer than the second parameter, the additional characters in the first parameter are ignored.

The first three parameters can be of type character, graphic, or UCS-2. All three must have the same type. The value returned has the same type and length as string.

The fourth parameter is a non-float numeric with zero decimal positions.

For more information, see String Operations or Built-in Functions.

Figure 270. %XLATE Example
 *..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
D up              C                   'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
D lo              C                   'abcdefghijklmnopqrstuvwxyz'
D string          S             10A   inz('rpg dept')

 /FREE

   string = %XLATE(lo:up:'rpg dept');
   // string now contains 'RPG DEPT'

   string = %XLATE(up:lo:'RPG DEPT':6);
   // string now contains 'RPG Dept'
 /END-FREE


[ Top of Page | Previous Page | Next Page | Contents | Index ]