CALLD
Estimated reading time: 2 minutes
Used to dynamically invoke the ENTRY procedure. [Only used with Monarch migrated programs].
Syntax
CALLD Pgm (Character expression)
ParmList (<u>*NONE</u>| Parameter List Name)
Err (Indicator Variable | *EXTENDED)
Lr (Indicator Variable)
Parameters
Pgm
Required. Pgm is required and is a character expression that evaluates to the name of the program to call. It can be a string constant, a field, or an expression that returns a string value.
During compilation of CALLD , if the Pgm keyword is a constant, the compiler searches the available dynamic references to obtain the signature of the *Entry method of the class, and match it against the parameters of the CALLD . If they’re not found, the parameters are assumed to be of the same type as the DclParm argument passed by reference, and with Option(*nopass) .
ParmList
Optional. ParmList specifies the list of parameters. *NONE is the default and indicates that there is not a parameter list.
If a ParmList is not given, CALLD may be followed by a group of DCLPARM commands specifying the parameters to be passed to the program. If a parameter is going to be omitted (the corresponding DclSrParm has the * OMIT option), use the special value *OMIT in the DCLPARM’s name.
Err
Optional. Err determines what the runtime will do if an error occurs while executing this command. The following rules apply:
- Err (Indicator Variable) - the specified Indicator is set if an error occurred.
- Err (*EXTENDED) - the program status flag is set whose status can be checked using the %ERROR built-in function.
- If the Err keyword is not given and an error occurs, a runtime exception will be thrown.
Lr
Optional. The specified indicator is set to the value of * INLR of the called program.
Remarks
CALLD is used to dynamically call programs, procedures, or subprocedures that are not known at compilation time. The assembly containing the callee must be available to be found at runtime or the call will fail. See the Monarch documentation for Calling a Program
Example
// Dynamic call to a dynamic program as a constant.
CALLD Pgm("MyNameSpace.MyProgram") ParmList(MyParmList)
// Dynamic call to a program as constant with the same Namespace as the caller.
CALLD Pgm(*NS + "MyProgram")
// Dynamic call to a program as a variable.
DclFld PgmToCall type( *string )
PgmToCall = "MyProgram"
CALLD Pgm( *NS + PgmToCall ) ParmList( Listout)