View previous topic :: View next topic
|
Author |
Message |
raak
Active User
Joined: 23 May 2006 Posts: 166 Location: chennai
|
|
|
|
hi
I came across a code like
PERFORM 1000-para THRU 1000-exit WITH TEST AFTER UNTIL eof-file.
Curious what this WITH TEST AFTER will do.. |
|
Back to top |
|
|
venosol Warnings : 1 New User
Joined: 16 Nov 2006 Posts: 43 Location: Bangalore
|
|
|
|
raak wrote: |
hi
I came across a code like
PERFORM 1000-para THRU 1000-exit WITH TEST AFTER UNTIL eof-file.
Curious what this WITH TEST AFTER will do.. |
It will execute the statements in 1000-Para Thru 1000-exit atleast once even after satisfying the condition.
Suppose the eof file is reached and it will execute the statements and then terminate the loop.
There is also WITH TEST BEFORE which will terminate the loop immediately after satisfying the condition without executing the statements.
If you didnot mention anything it will take WITH TEST BEFORE as default. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Raak,
An important diff between BEFORE/AFTER is shown in the following:
Code: |
01 SUB PIC S9(004) COMP VALUE 1.
PERFORM 1000-para THRU 1000-exit WITH TEST AFTER UNTIL SUB >= 1
PERFORM 1000-para THRU 1000-exit WITH TEST BEFORE UNTIL SUB >= 1
|
SUB is incemented by 1 in 1000-para.
The PERFORM BEFORE will not exec 1000-para.
The PERFORM AFTER will exec 1000-para once.
If you change the >= to >:
The PERFORM BEFORE will exec 1000-para once.
The PERFORM AFTER will exec 1000-para twice. |
|
Back to top |
|
|
livingston
New User
Joined: 20 Feb 2007 Posts: 6 Location: India
|
|
|
|
hi
By default the perform statement perform the paragraph only if the condition that you have specified is true.
it can be overridden by using WITH TEST AFTER ie the paragraph is atleast executed even the condition that you have specified is false.
i think you can be clear now! |
|
Back to top |
|
|
|