Replaces some of the characters in a character expression by a pair of characters and returns a nonvarying string.
REPLACEBY2 (x, y, z)
foo: proc options(main);
     dcl str char (26);
     dcl t   char(64) var;
     dcl s1 char (4) init('X!P?');
     dcl s2 char (2) init('xp');
     dcl i fixed bin (31);
     dcl c1 char (4) init ('X!P?');
     dcl c2 char (2) init ('xp');
     str = 'xbcxyzghijklmnopqrstuvwxyz';
     if 'a' = 'a'A then
         t = replaceby2 (str, '5821503F'x, '7870'x);
     else
         t = replaceby2 (str, 'E75AD76F'x, 'A797'x);
     put skip list (t);
     t = replaceby2 (str, s1, s2);
     put skip list (t);
end; 
               	 None.
Description
REPLACEBY2 returns a nonvarying string which is formed by replacing some of the characters in the expression x by a pair of characters.
If a character in x is found in z, the character pair corresponding to it is copied to the result. Otherwise, the character in x is copied directly to the result. If z contains duplicate characters, the leftmost occurrence is used.
The string y must be twice as long as the string z.