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

Need solution for this Infinite loop?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 174
Location: Bangalore

PostPosted: Thu May 11, 2006 12:53 pm
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
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: 1208
Location: Bangalore,India

PostPosted: Thu May 11, 2006 2:02 pm
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
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
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
Reply with quote

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

New User


Joined: 21 Jul 2005
Posts: 56
Location: Hyderabad

PostPosted: Fri May 12, 2006 10:56 am
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. REXX - Do - Not able to LOOP CLIST & REXX 10
No new posts SDSF like solution in EJES (store com... All Other Mainframe Topics 4
No new posts REXX - Dataset checking in a do forev... CLIST & REXX 6
No new posts Need to read duplicate rows from tabl... DB2 3
No new posts A very ingenious mainframe automation... CA Products 1
Search our Forums:

Back to Top