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
 

 

Need solution for this Infinite loop?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
abhicet2003

New User


Joined: 16 Nov 2005
Posts: 21

PostPosted: Thu May 11, 2006 12:05 pm    Post subject: Need solution for this Infinite loop?
Reply with quote

Hi,
Please give me the solution for this.

01 WS-COUNT PIC9 VALUE 5

PERFORM XX-PARA WS-COUNT TIMES

XX-PARA.
MOVE 10 TO WS-COUNT



HOW many times xx-para will get executes?

Thanks
Back to top
View user's profile Send private message

shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 171
Location: Bangalore

PostPosted: Thu May 11, 2006 12:53 pm    Post subject:
Reply with quote

Hi abhicet2003,

It will execute just 5 times. that's it
Correct me if I am wrong
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Thu May 11, 2006 1:53 pm    Post subject:
Reply with quote

Hi,

It will execute 5 times.

PERFORM N TIMES executes the section/para N times irrespective of vale of N being modified later.

This is not an infinite loop.

Thanks,
Parikshit
Back to top
View user's profile Send private message
guptae

Moderator


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

PostPosted: Thu May 11, 2006 2:02 pm    Post subject:
Reply with quote

It will execute only 5 times
Back to top
View user's profile Send private message
sandeep4u

New User


Joined: 12 Aug 2005
Posts: 32

PostPosted: Thu May 11, 2006 3:14 pm    Post subject: Re: Infinite loop?
Reply with quote

Hi,

It will execute only five times..definately..

correct me i m wrong...

thanks,

sandy
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu May 11, 2006 7:56 pm    Post subject: Re: Infinite loop?
Reply with quote

abhicet2003,

I know I'm being a Smart A--, but it will execute 6 times, 5 for the "PERFORM WS_COUNT TIMES" and once it will fall through XX_PARA.

Dave icon_razz.gif
Back to top
View user's profile Send private message
abhicet2003

New User


Joined: 16 Nov 2005
Posts: 21

PostPosted: Fri May 12, 2006 7:53 am    Post subject: Re: Infinite loop?
Reply with quote

Thanks a lot for your Quick response.
Back to top
View user's profile Send private message
ajayvamsi
Currently Banned

New User


Joined: 21 Jul 2005
Posts: 56
Location: Hyderabad

PostPosted: Fri May 12, 2006 10:56 am    Post subject:
Reply with quote

it wil execute only 1 time
Back to top
View user's profile Send private message
IQofaGerbil

Active User


Joined: 05 May 2006
Posts: 183
Location: Scotland

PostPosted: Fri May 12, 2006 7:34 pm    Post subject: Re: Infinite loop?
Reply with quote

01 WS-COUNT PIC9 VALUE 5

MOVE 10 TO WS-COUNT

Do you realise that WS-COUNT will have value of 0 after that MOVE statement?

However if you code

01 WS-COUNT PIC 99 VALUE 5

then the value will be 10.

The paragraph will execute 5 times because Cobol stores the initial WS-COUNT value in a seperate register.

However if you were to subsequently repeat the
PERFORM XX-PARA WS-COUNT TIMES

it would then execute it 10 times (or whatever value was in WS-COUNT at the time of the 2nd execution)
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat May 13, 2006 6:28 pm    Post subject:
Reply with quote

Another "Smart A"-- ans:

It will not compile. PIC9 (no space) is invalid.
Back to top
View user's profile Send private message
philipraju
Warnings : 1

New User


Joined: 16 Apr 2006
Posts: 29

PostPosted: Mon May 15, 2006 9:23 am    Post subject: Hi,Abichet
Reply with quote

It will executes defineitely for 5 times only,because of we cant overwright the value of the variable i.e.in the loop,here we assigning the value in first para and then overwriting the same variable with some other value,that is aplicable to that particular para only(i think),not for calling para.


..............corret Me if im wrong
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Mon May 15, 2006 12:40 pm    Post subject:
Reply with quote

Good catch mmwife icon_biggrin.gif
Back to top
View user's profile Send private message
swamy

New User


Joined: 22 Jul 2005
Posts: 1
Location: banglore

PostPosted: Fri Sep 01, 2006 7:26 pm    Post subject: swamy
Reply with quote

it will executes five times only....

thanks

Swamy
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 save SAY var loop. italo_pm CLIST & REXX 3 Sun Sep 04, 2016 3:06 am
No new posts print out the correct info in LOOP? jackzhang75 CLIST & REXX 7 Wed Dec 23, 2015 10:39 pm
This topic is locked: you cannot edit posts or make replies. Need help in design the solution ritnihi PL/I & Assembler 1 Tue Dec 22, 2015 1:48 pm
No new posts Using different values for Skeleton d... venksiv CLIST & REXX 8 Thu Sep 03, 2015 5:28 pm
No new posts Issue with Do Loop. santosh_g CLIST & REXX 5 Tue May 12, 2015 9:24 am


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