Page 1 of 1

GOTO statement function

PostPosted: Mon Feb 25, 2008 5:16 pm
by Ajith Kumar
Here, i have included coding part. Can anyone give the answer?
will the control back to para-1 if i execute goto statement????

Program:

Perform para-1 thru para-1-exit.
para-1.
Move 1 to ws-count
Display 'aaaa'
Goto para-2
para-1-exit.
Exit.

para-2.
Display 'bbbb'.

Re: GOTO statement function

PostPosted: Mon Feb 25, 2008 5:54 pm
by CICS Guy
Ajith Kumar wrote:Here, i have included coding part. Can anyone give the answer?
will the control back to para-1 if i execute goto statement????

Program:
Perform para-1 thru para-1-exit.
para-1.
       Move 1 to ws-count
       Display 'aaaa'
       Goto para-2
para-1-exit.
       Exit.

para-2.
       Display 'bbbb'.
No, whatever is after para-2 will be executed...
If nothing is after para-2, an implicit stop run/goback will take place.

Re: GOTO statement function

PostPosted: Tue Feb 26, 2008 10:51 am
by Ajith Kumar
Suppose if there is an 'DISPLAY "cccc"' statement after GOTO statement, will 'cccc' displayed or not?

Re: GOTO statement function

PostPosted: Tue Feb 26, 2008 4:33 pm
by arunprasad.k
Ajith Kumar,
Did you tried running your code? You have given the code, then why are you hesitating to run that? Try that and let us know.
Arun.

Re: GOTO statement function

PostPosted: Tue Feb 26, 2008 7:08 pm
by CICS Guy
Ajith Kumar wrote:Suppose if there is an 'DISPLAY "cccc"' statement after GOTO statement, will 'cccc' displayed or not?
Of course not, why would you even think it might?

Re: GOTO statement function

PostPosted: Tue Feb 26, 2008 9:30 pm
by pcdoctor
Perform cannot contain goto because goto takes the control out of the perform and the control is not returned back.So in your case the control will never come back to para1..To chk ths jus give a display statement in para-1-exit and chk out..Correct me if am wrong pls..

Regards
Nadeem

Re: GOTO statement function

PostPosted: Wed Feb 27, 2008 4:10 am
by CICS Guy
pcdoctor wrote:Perform cannot contain goto because goto takes the control out of the perform and the control is not returned back.
A rather broad statement.....and not entirely correct.....
If the perform was in the paragraph through paragraph form, the 'go to'ed branch could return to a paragraph within the preformed loop....

Re: GOTO statement function

PostPosted: Wed Feb 27, 2008 4:16 am
by dick scherrer
Hello,

There is also often a big difference between what the compiler will allow and what is good programming practice. . .

Re: GOTO statement function

PostPosted: Wed Feb 27, 2008 4:22 am
by CICS Guy
pcdoctor wrote:Perform cannot contain goto because goto takes the control out of the perform and the control is not returned back.
FWIW, usually the only 'GO TO's I've seen have been to an abend routine or an EOJ routine.....