Hi,
If a program is dynamically linked, are values retained in working storage if this sub-program is called multiple times from the same source program? Can someone please guide me on this.
Thanks.
Working storage of called program.
-
- Registered Member
- Posts: 22
- Joined: Thu Mar 17, 2016 9:54 pm
Re: Wroking storage of called program.
I believe that this information is in one of the COBOL manuals - Language Reference or User Guide both of which you should have referred to before posting. Once you have referred to them come back with any questions that you may have about that information. Manuals can be a bit tricky to understand especially if they are not in your first language.
Regards
Nic
Nic
- Robert Sample
- Global Moderator
- Posts: 1896
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Wroking storage of called program.
Have you looked at the CANCEL statement in the Language Reference manual? Have you looked at the definition of run unit ? If not, you have some reading to do.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Working storage of called program.
Wherever your sub-program is CALLed from, its previous WORKING-STORAGE values will be retained.
If you don't want that behaviour (for all or some of your fields) define the fields in the LOCAL-STORAGE SECTION. Fields in LOCAL-STORAGE are reallocated on each CALL. If they are defined with a VALUE clause, they are reset to that value. If they have no VALUE clause, their content is undefined.
IS INITIAL on the PROGRAM-ID makes the WORKING-STORAGE behave like LOCAL-STORAGE.
CANCEL (indicating an appropriate name) remove the sub-program from storage (assuming it is there) such that the next time it is CALLed, its WORKING-STORAGE has initial values. Remembering, again, those items with no VALUE clause have no pre-determined value.
The "no pre-determined value" is not strictly true, as the behaviour can me modified by a Language Environment (LE) run-time option. But, hopefully you are not using that option. For the saving of the effort of using the word VALUE with a literal is a run-time overhead for each initial CALL. So a losing, not a saving.
If you don't want that behaviour (for all or some of your fields) define the fields in the LOCAL-STORAGE SECTION. Fields in LOCAL-STORAGE are reallocated on each CALL. If they are defined with a VALUE clause, they are reset to that value. If they have no VALUE clause, their content is undefined.
IS INITIAL on the PROGRAM-ID makes the WORKING-STORAGE behave like LOCAL-STORAGE.
CANCEL (indicating an appropriate name) remove the sub-program from storage (assuming it is there) such that the next time it is CALLed, its WORKING-STORAGE has initial values. Remembering, again, those items with no VALUE clause have no pre-determined value.
The "no pre-determined value" is not strictly true, as the behaviour can me modified by a Language Environment (LE) run-time option. But, hopefully you are not using that option. For the saving of the effort of using the word VALUE with a literal is a run-time overhead for each initial CALL. So a losing, not a saving.
-
- Registered Member
- Posts: 22
- Joined: Thu Mar 17, 2016 9:54 pm
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute