View previous topic :: View next topic
|
Author |
Message |
sunnybunny
New User
Joined: 29 Nov 2005 Posts: 49
|
|
|
|
Hi,
Could you please answer for these questions.
1. Difference between EXIT & EXIT-PROGRAM?
2. Difference between EXIT & GOBACK?
3. What will happen if i code GOBACK & STOP RUN in same program?
4. I have a following structure.
01 A PIC X(100) VALUE 'NAME SALARY NAME SALARY NAME SALARY
...........'
Like that 100 characters. Now i want to display the above one is as follows.
NAME SALARY
NAME SALARY
.
.
.
NAME SALARY.
Please tell me the code for this.
Please let me know the answers for above questions.
Thanks,
Sunny. |
|
Back to top |
|
|
martin9
Active User
Joined: 01 Mar 2006 Posts: 290 Location: Basel, Switzerland
|
|
|
|
hy sunnybunny,
1. EXIT means EXIT from a paragraph you just performed,
EXIT-PROGRAM you finish the program.
2. GOBACK you code normally for subroutines,
it is like EXIT-PROGARM but returns to the caller.
3. EXIT-PROGRAM is like STOP-RUN...
finishing the program
4. 01 A PIC X(100) VALUE 'NAME SALARY NAME SALARY NAME SALARY...
i assume NAME and SALARY alre always from different length.
if so, then STRING/UNSTRING this stuff. if the sizes for NAME and SALARY
are from the same length, i.e. NAME PIC X(20), SALARY PIC 9(05),
then you can redefine your variable with an array, and display its value
in a loop....
martin9 |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi Martin,
Quote: |
2. GOBACK you code normally for subroutines,
it is like EXIT-PROGARM but returns to the caller. |
Is there any difference between GOBACK & EXIT-PROGRAM. Basically GOBACK returns the control to caller if coded in a called module or simply STOP FUNCTIONS if coded in Main module.
And Isn't EXIT-PROGRAM doing the same.
Regards,
Priyesh. |
|
Back to top |
|
|
martin9
Active User
Joined: 01 Mar 2006 Posts: 290 Location: Basel, Switzerland
|
|
|
|
hy priyesh,
actually yes,
STOP RUN will break any flow...
therefore you are right.
martin9 |
|
Back to top |
|
|
cheryala
New User
Joined: 20 Mar 2006 Posts: 46
|
|
|
|
Hi Everybody,
Just i need to add some more info ..
EXIT-PROGRAM-------> No action will be taken if you use it in your main program ..but if you use it in any sub program then the control will transfer to calling program.
GOBACK---------> When it is used in the main program, stops the program when executed and control will be returned to OS....where is when it is used in subprogram, control will be returned to the calling program..
STOP RUN ---> When it is executed either in main program or sub program, program execution will be stopped and the control will be returned to OS.
Please let me know if i'm wrong any where..
Thanks and Regards,
RS |
|
Back to top |
|
|
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
Hi,
Just wanted to add a point regarding this.
I saw the replies and found one of the answers as
"EXIT means EXIT from a paragraph you just performed"
As far as I know, it doesnt do that !!
A paragraph identifies that it is done when it encounters a new PARA AND NOT when it encounters exit. So basically EXIT does nothing and is just a way of coding.
Any corrections and always welcome.
ap_mainframes |
|
Back to top |
|
|
gowtham_1982 Warnings : 1 Active User
Joined: 02 Dec 2005 Posts: 109
|
|
|
|
ap_mainframes wrote: |
Hi,
Just wanted to add a point regarding this.
I saw the replies and found one of the answers as
"EXIT means EXIT from a paragraph you just performed"
As far as I know, it doesnt do that !!
A paragraph identifies that it is done when it encounters a new PARA AND NOT when it encounters exit. So basically EXIT does nothing and is just a way of coding.
Any corrections and always welcome.
ap_mainframes |
i too support ap_mainframes. to add with, a paragraph also ends when it finds there are no more statement to be executed from it. an EIXT statement does nothing other than to exit from the paragraph. if an EXIT statement is coded, it should be the only statement in the paragraph.
sorry if i'm revisiting the grounds agains.
kind regards,
gowtham |
|
Back to top |
|
|
umeshkmrsh
New User
Joined: 21 Sep 2005 Posts: 79 Location: India
|
|
|
|
EXIT statement does nothing. It never exists from a paragraph. A paragraph ends when we reach another para or section.
As every peragraph needs to have at least one statement, we use EXIT as its more meaningful.
I hope this makes it clear that why EXIT is used and what it does. |
|
Back to top |
|
|
umeshkmrsh
New User
Joined: 21 Sep 2005 Posts: 79 Location: India
|
|
|
|
cheryala wrote: |
Hi Everybody,
Just i need to add some more info ..
EXIT-PROGRAM-------> No action will be taken if you use it in your main program ..but if you use it in any sub program then the control will transfer to calling program.
GOBACK---------> RS |
Are you sure that EXIT-PROGRAM does nothing when used in main program? I doubt it does nothing.
Anyone please clear this topic, as most of the replies are contradictory.
What is diff bet EXIT-PROGRAM , GOBACK and STOP RUN.
What is know is:
STOP RUN -- stops current rununit (wherever it is used main or sub program)
GOBACK = EXIT-PROGRAM --- (if used in main program they are = STOP RUN and if used in sub-program they return control to main program).
Please correct if I am wrong. |
|
Back to top |
|
|
tusharguptait
New User
Joined: 15 Feb 2006 Posts: 32
|
|
|
|
Hi,
->STOP RUN is the last executable statement of the main program ( or sub program ). It returns control back to OS.
->GOBACK can be coded in main program as well as sub-program as the last statement. It just gives the control back from where it received the control.
->EXIT PROGRAM is the last executable statement of sub-program. It returns control back to main program. However in main program the EXIT PROGRAM will act as a NULL statement and execution will continue from next impertative statement.
->EXIT acts as a NULL statement and does nothing. If used it should be the only statement in the para.
Thanks.
TG |
|
Back to top |
|
|
mubashir.surury
New User
Joined: 29 Sep 2005 Posts: 23 Location: Pune
|
|
|
|
hi sunnybunny;
for your last question u can use REDEFINES clause in the foolowing manner.assuming name and sakary both are 5 bytes long.
Code: |
01 A PIC X(100) VALUE 'NAME SALARY NAME SALARY NAME SALARY
01 B REDEFINES A.
05 NAME-SALARY OCCURS 10 TIMES INDEXED BY X.
10 NAME PIC X(5).
10 SALARY PIC 9(5).
|
and then you can use PERFORM statement to display the same on a new line each.
Code: |
PERFORM VARYING X FROM 1 BY 1 UNTIL X = 10
DISPLAY NAME-SALARY(X)
END-PERFORM.
|
just check on the use of index for an array.i am not sure of the syntax.
hope that helps.
corrections are welcome |
|
Back to top |
|
|
|