View previous topic :: View next topic
|
Author |
Message |
Angayarkannipm
New User
Joined: 13 Sep 2008 Posts: 4 Location: Chennai
|
|
|
|
Hi all,
i am new to this Forum.Let me know how to retain the Values of working Storage Variable's values.
For Example,
COB1 is a COBOL Program
ASM1 is an Assembler Program
ASM1 Calling COB1 more than Once. What's a Problem means the Values of the variables in working storage isn't RETAINING.
For me, I should Retain the Values of that Variables Of COB1 .
Help me! |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Not sure if I've understood the question correcly - you can define an array, keep "storing" the valus in that for different index/subscript. |
|
Back to top |
|
|
Angayarkannipm
New User
Joined: 13 Sep 2008 Posts: 4 Location: Chennai
|
|
|
|
Hi Anuj,
thanks. but that array also declared in the working Storage Section of the COBOL Program.
If i Will call the Same Program 2nd time means all the variables have it's new value(including That ARRAY). am i right? |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
search for IS INITIAL clause in the PROGRAM-ID paragraph. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
If i Will call the Same Program 2nd time means all the variables have it's new value(including That ARRAY). am i right? |
It depends on what you want to happen. . .
Quote: |
the Values of the variables in working storage isn't RETAINING |
RETAINING is not a feature. . .
When the cobol program is re-invoked, do you want the initial values in the COBOL or do you want the values to persist as they were at the end of the first call? |
|
Back to top |
|
|
Angayarkannipm
New User
Joined: 13 Sep 2008 Posts: 4 Location: Chennai
|
|
|
|
hi,
Thanks.
Yes,i want the values to persist as they were at the end of the first call. |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hello Angayarkannipm,
The working-storage section is allocated at the start of the run-unit and any data items with VALUE clauses are initialized to the appropriate value at the time. When the subprogram is called the second time, a working-storage items persist in their last used state. However, if the program is specified with INITIAL on the PROGRAM-ID, working-storage section is reinitialized each time the program is entered. |
|
Back to top |
|
|
Angayarkannipm
New User
Joined: 13 Sep 2008 Posts: 4 Location: Chennai
|
|
|
|
hi,
thanks for your Replay.
In my secenrio,my main program is in Assembler and my subprogram is in COBOL and added to that i didn't use INITIAL in my PROGRAM-ID pharagraph.
while my main program reinvoked my sub program the variables in sub program is initialed automatically
Please Help me..... |
|
Back to top |
|
|
Krishna Velamur
New User
Joined: 22 Aug 2008 Posts: 22 Location: Hyderabad
|
|
|
|
Hi,
As explained in the previous posts, the working storage values will be retained if the submodule is called more than once. To avoid this we specify IS INITIAL in Program Id.
Also, if a COBOL program is calling a sub module, we can initialize working storage by using CANCEL verb after the CALL. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello Angayarkannipm,
To easily do what you want, pass all of the variables from the calling module.
The called module will have no values "of its own" (except constants). When control is returned to the calling module any variables that were updated in the called module will be preserved/available in the caller.
When the called module is invoked again, the caller automatically provides everything. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
The COBOL program should be loaded once only.
During the load, fields are set to their default values.
As you don't have the INITIAL option in the PROGRAM-ID paragraph,
the values should be retained between the calls.
If they are not, maybe you are reloading the program ?
Please show us the pieces of code in your ASM program where you deal with the COBOL subprogram. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi,
Sounds likeyou want to make your subpgm "seriallly reuseable".
REUS is a link edit option. It's use comes with a few caveats. Do some research on REUS and RENT (a compiler opt).
While I don't think you want RENT, the topic contains more than a few references to REUS. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
As i mentioned before:
Quote: |
To easily do what you want, pass all of the variables from the calling module. |
If you try this, you will notice the overall size of the executed code will not change much and there should be no performance "hit" as the only thing that will change is addressability.
As Jack mentioned, you should not need your code to be re-entrant.
If you try having all of the variables n the caller, you would still want to make sure that the called module is not reloaded every time it is called. |
|
Back to top |
|
|
|