Thanks Dave.  That seemed to work for part of it, but I am getting an error if 
I am trying to assign a value to the variable within the loop; i.e. assign a 
value using this type of variable.  For example if I want to print out the 
numbers 1,2,3 then the code below gives me an error.  It is saying that it is 
an invalid symbolic variable.  How do I reference the variable in this case?  
Thanks for your help and unfortunately it isn't really feasible to stick with 
Rexx for this since there are already thousands of lines of code written in 
CLIST that I just need to modify a bit.    

/* This CLIST demonstrates how to create an array.                   */
/**********************************************************************/
SET &COUNT = 1
DO WHILE &COUNT < 4
   SET &&COLOR&COUNT = &COUNT
   SET &TEMP = &&COLOR&COUNT
   WRITE &TEMP
   SET &COUNT = &COUNT + 1
END

Regards,
Nick Pullman


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[EMAIL PROTECTED] Behalf Of Dave 
Salt
Sent: Wednesday, February 08, 2006 6:10 PM
To: IBM-MAIN@BAMA.UA.EDU
Subject: Re: CLIST array variable?

Hi Nick,

If you already know REXX my advise would be stay away from CLIST as REXX is
much more powerful. If there's some reason why you can't do that and you
absolutely have to use CLIST, you can create an array by prefixing variables
with adjoining ampersands. For example:

/* This CLIST demonstrates how to create an array.                   */
/**********************************************************************/
SET &COLOR1 = RED
SET &COLOR2 = BLUE
SET &COLOR3 = GREEN
SET &COUNT = 1
DO WHILE &COUNT < 4
   SET &TEMP = &&COLOR&COUNT
   WRITE &TEMP
   SET &COUNT = &COUNT + 1
END

The above loop executes 3 times, and each time through it displays a color
(i.e. RED, BLUE, or GREEN). This is how it works:

When CLIST encounters 2 or more ampersands, it simply drops the first
ampersand. Therefore, &&COLOR becomes &COLOR. The variable &COUNT only has a
single ampersand, so the first time through the loop the value of &COUNT is
resolved and becomes 1. The overall net effect is that &TEMP is set to
&COLOR1; i.e. &TEMP is set to a variable NAME (and not the actual contents
of the variable). When the WRITE occurs, the value of the variable &COLOR1
is resolved, and so the word RED is written. Rinse and repeat, and the next
colors are displayed.

As I said, REXX is a lot easier.    :-)

Hope this helps,

Dave Salt
SimpList(tm) - The easiest, most powerful way to surf a mainframe!
http://www.mackinney.com/products/SIM/simplist.htm


 

----------------------------------------------------------------------
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

Reply via email to