CTRAN Without Pain
Problem:
Started from an old post on Focal Point: trying to use this CTRAN Subroutine to translate a comma into a space, but don't know the deciaml value of a comma:
CTRAN( inlen, infield, decfrm, decto, output )
decfrm is the "decimal value of the character to be traslated"
The question turns to: can you use CTRAN without having to figure out the Hex value (which is different for ASCII and EBCDIC)?
Solution:
Original syntax:
CTRAN(charlen, string, decimal, decvalue, outfield); BYTVAL(character, outfield);
Adapted syntax:
CTRAN(charlen, string, BYTVAL('from','I3'), BYTVAL('to','I3'), outfield);
e.g.:
-*-- Convert Apostrophe to Right Single Quotation Mark -------------------------
-SET &OBJ_NAME4 = CTRAN(&OBJ_NAME.LENGTH, &OBJ_NAME, BYTVAL('''','I3'), BYTVAL('’','I3'),
'A&OBJ_NAME.LENGTH');
-*-- Convert Slash and Dash to blank -------------------------------------------
RGN1/A50 = CTRAN(50, RGN0, BYTVAL('/','I2'), BYTVAL(' ','I2'), 'A50');
RGN2/A50 = CTRAN(50, RGN1, BYTVAL('-','I2'), BYTVAL(' ','I2'), 'A50');
You will never have to look for an ASCII or EBCDIC chart again! This tip is also posted on Focal Point.
If any questions, please contact Francis at fm@francismariani.com.