On 5/9/2007 9:50 PM, David E. wrote:
I have inherited responsibility for a CLIST; this is not my forte. I'm
trying to do something pertaining to the ampersand character, and despite my
efforts, I cannot figure this out. As God is my witness, this is not a
homework assignment (I'm a BAL programmer, not a sysprog).
I've carved out and simplified the relevant portion of the CLIST for
perusal:
WRITENR ===>
READ L
DO &K=1 TO &LENGTH(&L)
IF &SUBSTR(&K,&L)=A THEN SET &X=&STR(&X) OPTA
ELSE IF &SUBSTR(&K,&L)=B THEN SET &X=&STR(&X) OPTB
ELSE IF &SUBSTR(&K,&L)=C THEN SET &X=&STR(&X) OPTC
END
WRITE &X
The CLIST above works, and the concept is simple. The user is prompted to
enter a string of characters chosen from the letters A, B, and C, each of
which is associated with the string OPTA, OPTB, and OPTC (respectively). The
CLIST sets X to the concatenation of these strings, delimited by blanks. So
if the user enters "BA", X is set to "OPTB OPTA". If the user enters "CCB",
X is set to "OPTC OPTC OPTB". Not hard.
The problem: I want each of the tokens in the generated string to be
preceded by a double-ampersand. E.g., if the user enters ACB, I want X to be
set to "&&OPTA &&OPTC &&OPTB".
I have read the manuals, I have tried everything I can think of... but the
ampersands have laid me low. Any help would be greatly appreciated.
Wherever you want 1 ampersand assigned you need to use 2.
So, as you want 2 ampersands you need to use 4, and thus I suggest trying:
IF &SUBSTR(&K,&L)=A THEN SET &X=&STR(&X) &&&&OPTA
ELSE IF &SUBSTR(&K,&L)=B THEN SET &X=&STR(&X) &&&&OPTB
ELSE IF &SUBSTR(&K,&L)=C THEN SET &X=&STR(&X) &&&&OPTC
Walt
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html