Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perform until with 2 conditions?

Status
Not open for further replies.

scallosa

ISP
Mar 7, 2002
76
US
Can the PERFORM UNRTIL have an OR condition.?
IE, perform x-routine until x = 7 or y = 8.

Thanks.
 
The short answer: Yes!

Also note that the COBOL standard specifies an order in which the terms of the conditional expression are evaluated. The standard specifies left-to-right evaluation, and further specifies that evaluation terminates as soon as the value of the conditional expression can be determined. Thus, using your example, when x=7 evaluates TRUE, TRUE ORed with any value is TRUE, so evaluation must terminate. The practical use of this is in a situation wherein if the first term is TRUE the evaluation of the second term might result in a runtime error:
Code:
PERFORM A-PARAGRAPH UNTIL
        A-SUBSCRIPT > SUBSCRIPT-LIMIT 
     OR A-TABLE (A-SUBSCRIPT) = SPACES.
Tom Morrison
 
Hi Tom,

How'd you dream up that example? :)

Jack
 
[bigsmile]

Yes, I just couldn't resist. Could be FAQ material, no?
Tom Morrison
 
Thank you very much for your timely reply.
I had looked in 4 count em 4 textbooks, and no one ever mentioned it. I finally did find it in the Stern and Stern book, which seems to be one of the more detailed books
of its kind.
Again, thank you.
 
Not a problem. Jack's comment is due to the fact that I used almost the same exact answer in another thread less than 24 hours earlier.

The fact that you may have a complex conditional expression probably obscures what most textbook authors are trying to accomplish with their examples, but it happens pretty often in real life. Stern and Stern is a good book.

[One way to reward good answers is to click on the link that allows you to mark a post as helpful or expert. I've got a ways to go to catch Jack!]

Best regards,
Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top