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
 

 

REXX 'end' delimiter in select & do statements, no loopi

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

New User


Joined: 30 Aug 2006
Posts: 14
Location: Tampa, Florida

PostPosted: Thu Aug 31, 2006 7:44 pm    Post subject: REXX 'end' delimiter in select & do statements, no loopi
Reply with quote

I have to maintain REXX code that is as follows:
Code:

select
    when (a & b) then
    do
        say 'a & b'
        submit jcl
    end
    when (a & c) then
    do
        say 'a & c'
        submit jcl
    end
    when (a & d) then
    do
        say 'a & d'
        submit jcl
    end
    otherwise
        whatever
end


The 3 'when-do's are repeated roughly 50 times for different conditions,
before the 'otherwise'.

I don't understand the use of the 'end' delimiter in 'when-do's. It seems that there shoud be just one 'end' and it should go before the 'otherwise' statement. With all the 'end' delimiters used, it seems that each condition is checked even if the previous condition is true, which is grossly inefficient because only 1 of the conditions can be true (eg. a & b).

I looked in several manuals and IBM online doco but there is no clear explanation of the simple 'end' delimiter, except in 'do' LOOPS- not in a straight 'do' that has no loopomg, like above.

The code is obviously inefficient due to the contant repetition of the test for 'a', in the beginning of each compound condition. The 'submit jcl' statements are also repeated. But I haven't been able to find out if these simple 'end' delimiters need to be repeated.

Can anyone tell me whether all these 'end' delimiters are needed for each 'do' or if this is just inefficient programming?

Thanx!
Back to top
View user's profile Send private message

cpuhawg

Active User


Joined: 14 Jun 2006
Posts: 331
Location: Jacksonville, FL

PostPosted: Thu Aug 31, 2006 8:01 pm    Post subject: Re: REXX 'end' delimiter in select & do statements, no l
Reply with quote

Every time you have a "THEN DO", you must have an END to close the "THEN DO".

You also need an "END" to close the SELECT.

The following code would prevent the use of so many END statements:

Code:

select
when (a & b) then say 'a & b'
when (a & b) then submit jcl
when (a & c) then say 'a & c'
when (a & c) then submit jcl
when (a & d) then say 'a & d'
when (a & d) then submit jcl
otherwise
whatever
end


If none of the whens are true, the program will execute the commands after "otherwise". If otherwise is missing, an error will result.
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2038
Location: Silicon Valley

PostPosted: Fri Sep 01, 2006 1:10 am    Post subject: REXX 'end' delimiter in select & do statements, no loopi
Reply with quote

Warren, you are mistaken about the syntax of the Select statement, which is:

Code:

Select
  When ( ) Then
  Otherwise
End


The DO is not part of the select statement. Following the WHEN and OTHERWISE, you can put any valid statement. Your code has:
Code:
 When (  )  Then   Do

Since the DO is not part of the SELECT, it wants to work like it always works: it has to have its normal delimiter, which is an end.

The DO / END statements are a way to group things together. I do not think the program will run without matching DO / END statements.

cpuhawg, I think your example is wrong. It will process one and only one WHEN statement. It will never do the second WHEN (A & B) THEN clause
Back to top
View user's profile Send private message
cpuhawg

Active User


Joined: 14 Jun 2006
Posts: 331
Location: Jacksonville, FL

PostPosted: Fri Sep 01, 2006 1:33 am    Post subject: Re: REXX 'end' delimiter in select & do statements, no l
Reply with quote

Pedro,

You are correct. Once a When condition is met, the program will branch to the END statement associated with the SELECT statement.

All the logic could be re-written without SELECT, such as:

Code:

if (a & b) then do
    say 'a & b'
    submit jcl
    signal nextstep
end
if (a & c) then do
    say 'a & c'
    submit jcl
    signal nextstep
end
if (a & d) then do
    say 'a & d'
    submit jcl
    signal nextstep
end
whatever
nextstep:


If it submits JCL from any if the "IF/THEN DO", it will drop down to the logic following nextstep. If no JCL are submitted, the whatever logic will be executed and the program will continue onward.
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
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Running an REXX EXEC implicitly sho7hills CLIST & REXX 3 Thu Apr 20, 2017 8:14 am
No new posts Need help in REXX CALL program Raje1002 CLIST & REXX 5 Wed Apr 19, 2017 11:18 pm
No new posts REXX cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm


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