View previous topic :: View next topic
|
Author |
Message |
santy Warnings : 1 New User
Joined: 19 Jul 2007 Posts: 22 Location: mumbai
|
|
|
|
What will happen if you code GO BACK instead of STOP RUN in a stand-alone COBOL program i.e. a program which is not calling any other program? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Dont you think such questions you should try out first and then if post if you stuck somewhere??? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The program will end. Many system standards dictate only goback be used (rather than stop run).
GOBACK terminats the current executing code and returns control to the code that invoked it (this could be a calling program or the operating system).
STOP RUN terminates the run unit - sometimes rather ungracefuly. |
|
Back to top |
|
|
santy Warnings : 1 New User
Joined: 19 Jul 2007 Posts: 22 Location: mumbai
|
|
|
|
but as it is stand-alone program, program will may b went to infinte loop also? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
but as it is stand-alone program, program will may b went to infinte loop also?
|
if you thinking GOBACK will call same program again then you are wrong.
is there any other reason that you are thinking so?[/code] |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
santy wrote: |
but as it is stand-alone program, program will may b went to infinte loop also? |
Unless there is a flaw in the logical flow.. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
From the Language Reference:
Quote: |
6.2.17 GOBACK statement
The GOBACK statement functions like the EXIT PROGRAM statement when it is coded as part of a called program (or the EXIT METHOD statement when it is coded as part of an invoked method) and like the STOP RUN statement when coded in a main program. |
If the program executes the GOBACK there is no infinite loop possible as the code is complete. If there is an infinite loop, the GOBACK is not being invoked. |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
The Goback won't cause pgm to go infinite loop
Just understand purpose of STOPRUN and GOBACK first
STOP RUN - Will pass control to OS(operating system)
GOBACK - will pass control to Calling program
In above acenario, we are having GOBACK for Standalone program so when GOBACK executed, it will look out pgm which is calling since it is not calling it gives control back to OS..
So there is no question of Looping here, Pgm will execute succesfully
Hope you are clear |
|
Back to top |
|
|
santy Warnings : 1 New User
Joined: 19 Jul 2007 Posts: 22 Location: mumbai
|
|
|
|
thanks,
now i clear my all doubts.... |
|
Back to top |
|
|
|