IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

what is the purpose of WITH TEST AFTER


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Fri Mar 30, 2007 3:33 pm
Reply with quote

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

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Fri Mar 30, 2007 3:44 pm
Reply with quote

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

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Apr 01, 2007 7:25 pm
Reply with quote

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

New User


Joined: 20 Feb 2007
Posts: 6
Location: India

PostPosted: Wed Apr 18, 2007 12:41 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Zunit Test case editor error Testing & Performance 4
No new posts Copying GDG version(all/few) from pro... CLIST & REXX 13
No new posts REXX Test under Mask??? CLIST & REXX 3
No new posts Assembler test under mask question PL/I & Assembler 5
No new posts a copybook getting improper values in... COBOL Programming 7
Search our Forums:

Back to Top