Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Alter control loop using compound variables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
pauly_william

New User


Joined: 15 Oct 2007
Posts: 27
Location: Canada

PostPosted: Thu Jun 26, 2008 8:14 pm    Post subject: Alter control loop using compound variables
Reply with quote

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
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jun 27, 2008 12:19 pm    Post subject:
Reply with quote

Maybe a shift in logic, but be warned - This code is untested and is intended purely as a guide icon_eek.gif

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
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Fri Jun 27, 2008 12:33 pm    Post subject: Reply to: Alter control loop using compound variables
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts save SAY var loop. italo_pm CLIST & REXX 3 Sun Sep 04, 2016 3:06 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm
No new posts Is it possible to pass variables of s... Csongor CLIST & REXX 2 Fri Jun 10, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us