View previous topic :: View next topic
|
Author |
Message |
Susanta
Active User
Joined: 17 Nov 2009 Posts: 126 Location: India
|
|
|
|
If Program A calls B, and compiler option is NODYNAM .
Then if we want to call Program B and want to to start program B as a fresh each time [initialized valriables when calling each time the program B].
How to do that without using DYNAM option?
Please help. |
|
Back to top |
|
|
technut
New User
Joined: 27 Dec 2007 Posts: 73 Location: India
|
|
|
|
Did some reading on this inside the forum and got the below info posted by Guptae.. might help..
A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.
Link...
ibmmainframes.com/viewtopic.php?t=708 |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Static or Dynamic calls are not related to what you want.
It just tells how and when the program is loaded into memory.
(search forum for more details)
technut is right, you can use INITIAL (in id division) or CANCEL (in procedure division).
You can also use LOCAL-STORAGE SECTION if you want to have both cases: part that is initialized each time (the L-S) and part not (the W-S). |
|
Back to top |
|
|
Susanta
Active User
Joined: 17 Nov 2009 Posts: 126 Location: India
|
|
|
|
Thanks a lot Technut and Marso. |
|
Back to top |
|
|
senjay
Active User
Joined: 10 May 2007 Posts: 147 Location: India
|
|
|
|
From Technut post,
Quote: |
A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state
|
Statically called subroutine cannot be deleted using CANCEL. From COBOL Programming guide,
Quote: |
Statically called programs cannot be deleted using CANCEL, so static calls might take more main storage. If storage is a concern, think about using dynamic calls. Storage usage of calls depends on whether: v The subprogram is called only a few times. Regardless of whether it is called, a statically called program is loaded into storage; a dynamically called program is loaded only when it is called. v You subsequently delete the dynamically called subprogram with a CANCEL statement. Chapter 24. Using subprograms 441
You cannot delete a statically called program, but you can delete a dynamically called program. Using a dynamic call and then a CANCEL statement to delete the dynamically called program after it is no longer needed in the application (and not after each call to it) might require less storage than using a static call.
|
Also A dynamically called subroutine will not be always in its initial state.
From COBOL programming guide,
Quote: |
The first dynamic call to a subprogram within a run unit obtains a fresh copy of the subprogram. Subsequent calls to the same subprogram (by either the original caller or any other subprogram within the same run unit) result in a branch to the same copy of the subprogram in its last-used state, provided the subprogram does not possess the INITIAL attribute.
|
|
|
Back to top |
|
|
|