| IBM MAINFRAME HELP FORUMS for COBOL, JCL, CICS, DB2, IMS etc... Help & Support Forums for IBM Mainframe computers Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7, CA-11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, VSAM, ISPF, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
|
| View previous topic :: View next topic |
| Author |
Message |
pauly_william
Joined: 15 Oct 2007
Posts: 10
Location: Canada
|
| Posted: Thu Jun 26, 2008 8:14 pm Post subject: Alter control loop using compound variables |
|
|
I'm trying to alter the boundaries of a loop using a compound variable (ie if condition is met move the end of an entry to another line). Hopefully the code illustrates better what I'm trying to accomplish:
Code:
/* rexx */
enum = 1
entry.enum.start = 4
entry.enum.stop = 6
Do i = entry.enum.start to entry.enum.stop
Say "Ln# :"i
If i = 5 Then entry.enum.stop = 10
End i
Output is:
Ln# :4
Ln# :5
Ln# :6
....instead of all the way to Ln# :10
So my question would be, is it possible to alter the loop inside when a condition is met or is the boundaries given will be the boundaries committed to? |
|
| Back to top |
|
expat
Joined: 14 Mar 2007
Posts: 3167
Location: Brussels once more ...
|
| Posted: Fri Jun 27, 2008 12:19 pm Post subject: |
|
|
Maybe a shift in logic, but be warned - This code is untested and is intended purely as a guide :shock:
Code:
/* rexx */
eof = 0
enum = 1
entry.enum.start = 4
entry.enum.stop = 6
i = entry.enum.start
Do until(eof)
Say "Ln# :"i
If i = 5 Then entry.enum.stop = 10
if i = entry.enum.stop
then eof = 1
i = i + 1
End
|
|
| Back to top |
|
enrico-sorichetti
Joined: 14 Mar 2007
Posts: 2647
Location: italy
|
| Posted: Fri Jun 27, 2008 12:33 pm Post subject: Reply to: Alter control loop using compound variables |
|
|
the logic behind is a bit odd, but....
the answer is nooo
the do loop boundaries are computed at do loop initialization
( You can check by running with TRACE "I" )
the only whay ( I tested ) is with a while
Code: start = 4
end = 6
i = start
do while ( i <= end )
say "i " i
if i = 5 then end = 10
i = i + 1
end |
|
| Back to top |
|
| |
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM
|