Converting the FREE operation code
To replace the function of the FREE operation, you must first determine why the FREE operation was being used.
- If the FREE operation was being used to ensure that the program would be initialized on the next call to the program, change the called program so that it may be called with a special parameter (or no parameter), indicating that it should simply set on LR and return. Then, instead of coding the FREE operation, call the program with the special "free" parameter.
* RPG III coding
C CALL 'MYPGM'
C PARM P1
...
C FREE 'MYPGM'
...
C CALL 'MYPGM'
C PARM P1
* Replacement RPG IV coding for the "reresolve" function of FREE
C call MYPGM_var
C parm p1
...
* Cause MYPGM to initialize on the next call
C call MYPGM_VAR
...
C call MYPGM_var
C parm p1
* Modified version of MYPGM. It ends itself when it is called with no parameters.
D SDS
D PARMS *PARMS
C *ENTRY PLIST
C PARM NAME 10
c PARMS IFEQ 0
C SETON LR
C RETURN
C ENDIF
...
- If the FREE operation was being used to cause the program containing the FREE operation to resolve to the program again on the next call to the program, then you can change your calling program so that you call using a character variable; to cause your called program to be resolved again, you must use the character variable to call a different program at the point where you would do your FREE; then when you use the character variable on the next CALL operation, the system would perform the resolve to your program again. Create a very quick-running program to be called for the "FREE" function, such as an ILE RPG program that simply has a RETURN operation.
* RPG III coding
C CALL 'MYPGM'
C PARM P1
...
C FREE 'MYPGM'
...
C CALL 'MYPGM'
C PARM P1
* Replacement RPG IV coding for the "reresolve" function of FREE
D MYPGM_var s 21a INZ('MYPGM')
C call MYPGM_var
C parm p1
...
* Cause a reresolve to MYPGM for the next call
C eval MYPGM_var = 'MYLIB/FREEPGM'
C call MYPGM_VAR
C reset MYPGM_var
...
C call MYPGM_var
C parm p1
To replace the function of the DEBUG operation, use an interactive debugger. For information on program debugging see Debugging Programs.