| Using CALLP with a Procedure Pointer |
|
|
|
Q. I read your tip about using CALLP with a variable program name. I want to do something similar, but with procedures. I want a program to choose one from among several different possible procedures to run, depending upon the contents of a database field. Is there a way to do this with CALLP? A. Sort of. The procedure cannot be a variable. Your program will need a prototype for every possible procedure. You'll also need a prototype to be associated with a procedure pointer. Then use the %PADDR function to assign a storage location to the procedure pointer. Here's an example: // Possible procedures to call The prototype for each procedure must be consistent with the prototype associated with the procedure pointer; that is, they must accept the same parameters. But you can include the OPTIONS(*NOPASS) and/or OPTIONS(*OMIT) keywords to make some parameters optional or omissible. |