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

Is this program (PERFORM VARYING) correct?


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

New User


Joined: 20 Feb 2007
Posts: 6
Location: India

PostPosted: Fri Apr 27, 2007 4:24 pm
Reply with quote

WORKING-STORAGE SECTION.
01 X 9 VALUE ZERO.
PROCEDURE DIVISION.
PERFORM VARYING X FROM 1 BY 1 UNTIL X<3
DISPLAY X
END-PERFORM
STOP RUN.

WHAT WILL BE THE OUT PUT OF THIS PROGRAM?
IT IS COMPILING WELL BUT AFTER RUNNING THE LOAD MODULE AND IF I CHECK FOR THE RESULT IN THE SPOOL AREA I COULDNT ABLE TO SEE THE SYSOUT THERE( I HAVE GIVEN THE SYSOUT IN THE JCL). PLEASE HELP ME TO SOLVE THE ISSUE.

Warning: Don't shout
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Fri Apr 27, 2007 4:31 pm
Reply with quote

Hi There,

U would not be able to see any value since it wont enter in the loop since u made the condition until X<3 So as soon as value of X will be less than 3 it will come out from the loop since syntactically its correct but not logically that s why u r not getting any compiler error . To see the value of X please change the code as below


Code:
PERFORM VARYING X FROM 1 BY 1 UNTIL X>3
DISPLAY X
END-PERFORM
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Apr 27, 2007 5:05 pm
Reply with quote

livingston wrote:
WHAT WILL BE THE OUT PUT OF THIS PROGRAM?
Exactly what you found, nothing. The condition was satisfied at the first test and since that test defaults to before, nothing within the perform executed.

Do yourself and the rest of us a favor and learn how to use the "Caps Lock" key on your keyboard (I know you read the forum rules.....).
Back to top
View user's profile Send private message
livingston

New User


Joined: 20 Feb 2007
Posts: 6
Location: India

PostPosted: Mon Apr 30, 2007 12:37 pm
Reply with quote

thank you very much!
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat May 05, 2007 8:52 pm
Reply with quote

What? Speak up ! I'm hard of seeing.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun May 06, 2007 10:33 pm
Reply with quote

I might as well add something constructive (somewhat) to the subject:

If you added "WITH TEST AFTER" to your stmt, the pgm would enter the PERFORM loop once and display the subscript.
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Using API Gateway from CICS program CICS 0
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
Search our Forums:

Back to Top