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!

Implementing Do-While in COBOL 1

Status
Not open for further replies.

hormise

Programmer
Oct 11, 2001
4
Hi Friends,

Do let me know How to implement Do-While in cobol .
It is using perform with Test Before option as far as i know

It would me helpful if some one could explain it with the help of an example
 
Hi Hormise,
I seem to recall that the DO WHILE condition compares most favourably with the PERFORM..... UNTIL...... WITH TEST AFTER statement, although I can't think of an example at the moment!

On a PERFORM with the WITH TEST AFTER bit, a test is made after execution to see if the condition is true. Without the WITH TEST AFTER the conditional test is made before execution.

Hope this helps
Marc
 
Just place an "If condition go to" at the end of the loop.

If you do not like my post feel free to point out your opinion or my errors.
 
As already mentioned, a simple PERFORM UNTIL/END PERFORM will do what you want. The default is to test the condition before execution, so there is no need to specify WITH TEST at all.
 
The COBOL PERFORM UNTIL {condition} is actually an implementation of the sructure DO WHILE NOT {condition}, so PERFORM UNTIL NOT {condition} is an exact implementation of DO WHILE {condition}.

The COBOL PERFORM WITH TEST AFTER UNTIL {condition} is an implemntation of DO UNTIL {condition}.
 
Webrabbit,
Thanks for clearing that up for me. I knew that the WITH TEST AFTER option had something to do with DO, but unfortunately I just couldn't remember what!
Thanks again,
Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top