EDIT: PROC (STRING,CODE) RETURNS (CHAR(255) VARYING); DCL (LENGTH,INDEX) BUILTIN; DCL STRING CHAR(*), CODE FIXED BIN(31); DCL CODES(0:8) BIT(1) BASED(ADDR(CODE)), I FIXED BIN, NEXT2 CHAR(2), NEXT CHAR(1) DEFINED(NEXT2), N FIXED BIN(15) DEFINED(NEXT2), OUT CHAR(255) VARYING, TABX FIXED BIN(07) STATIC INIT(9), TAB CHAR(1) DEFINED(TABX), (REDUNDANT, QUOTED, LC, SP) BIT(1); DCL (LEFT,RIGHT) ENTRY (CHAR(*),FIXED BIN) RETURNS (CHAR(255) VARYING), CHR ENTRY (FIXED BIN) RETURNS (CHAR(1)), ASCII ENTRY (CHAR(*)) RETURNS (FIXED BIN); N=0; OUT=''; QUOTED='0'B; REDUNDANT='0'B; DO I=1 TO LENGTH(STRING); NEXT=SUBSTR(STRING,I,1); IF CODES(0) & (N>127) THEN N=N-128; LC=(N>96 & N<123); SP=(N=9 ! N=32); IF ((CODES(8) & (QUOTED ! NEXT='''')) ! ^((CODES(1) & SP) !(CODES(2) & (N=0 ! N=10 ! N=12 ! N=13 ! N=27 ! N=255)) !(CODES(4) & SP) !(CODES(5) & LC) !(CODES(6) & (NEXT='[' ! NEXT=']')))) THEN OUT=OUT!!NEXT; ELSE DO; IF (^CODES(1) & CODES(4) & ^REDUNDANT & SP) THEN OUT=OUT!!' '; ELSE DO; IF (CODES(5) & LC) THEN OUT=OUT!!CHR(N-32); ELSE DO; IF (CODES(6) & NEXT='[') THEN OUT=OUT!!'('; ELSE DO; IF (CODES(6) & NEXT=']') THEN OUT=OUT!!')'; ELSE /* NO OUTPUT */; END; END; END; END; IF NEXT='''' THEN QUOTED=^QUOTED; REDUNDANT=SP; END; DO WHILE (CODES(3) & LENGTH(OUT)>0 & (SUBSTR(OUT,1,1)=' ' ! SUBSTR(OUT,1,1)=TAB) ); OUT=SUBSTR(OUT,2); END; DO WHILE (CODES(7) & LENGTH(OUT)>0 & (SUBSTR(OUT,LENGTH(OUT))=TAB !SUBSTR(OUT,LENGTH(OUT))=' ') ); OUT=SUBSTR(OUT,1,LENGTH(OUT)-1); END; RETURN(OUT); END;