The FETCH statement checks main storage for the named procedures. Procedures not already in main storage are loaded from the disk.
The entry-constant must be the same as the one used in the corresponding CALL statement, CALL option, or function reference.
If the load module is later released by the RELEASE statement, and the load module is accessed (through the pointer), unpredictable results can occur.
For example:
dcl A entry;
dcl B entry ext('C');
dcl T char(20) varying;
T = 'Y';
fetch A title('X'); /* X is loaded */
fetch A; /* A is loaded */
fetch B title('Y'); /* Y is loaded */
fetch B; /* C is loaded */
fetch B title(T); /* Y is loaded */
For more detailed information on title strings, refer to the Programming Guide.
The RELEASE statement frees the main storage occupied by procedures identified by its specified entry constants.
|
If the module has never been fetched in the same external procedure before or has already been released, the entry constant is the null pointer. No release is performed, no message is issued and execution continues with the statement that follows the RELEASE statement.
Consider the following example, in which ProgA and ProgB are entry names of procedures resident on disk:
Prog: procedure; 1 fetch ProgA; 2 call ProgA; 3 release ProgA; 4 call ProgB; go to Fin; fetch ProgB; Fin: end Prog;
The same results would be achieved if the statement FETCH ProgA were omitted. The appearance of ProgA in a RELEASE statement causes the statement CALL ProgA to load the procedure, as well as invoke it.
The fetched procedure is compiled and linked separately from the calling procedure. You must ensure that the entry constant specified in FETCH, RELEASE, and CALL statements; CALL options; and in function references is the name known on the disk. This is discussed in the Programming Guide.