Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Is this program (PERFORM VARYING) correct?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Is this program (PERFORM VARYING) correct?
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: 1187
Location: Bangalore,India

PostPosted: Fri Apr 27, 2007 4:31 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Fri Apr 27, 2007 5:05 pm    Post subject: Re: IS THIS PROGRAM(PERFORM VARYING) CORRECT?
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Is the explanation correct? XRST,CHKP Martylin IMS DB/DC 1 Wed Mar 15, 2017 9:26 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us