Try OpenEdge Now
skip to main content
Dynamic Call Object
Code examples : Running an internal procedure of a persistent external procedure
 

Running an internal procedure of a persistent external procedure

The following example, which illustrates using a single call object multiple times, is a bit more complicated than that shown in Attributesof a call object handle. This example also shows how to:
*Dynamically invoke the external procedure persis.p persistently
*Dynamically invoke an internal procedure of persis.p, internal-persis-proc, with an input parameter of type "INTEGER" and with the value 333
DEFINE VARIABLE hCall AS HANDLE NO-UNDO.

CREATE CALL hCall.

/* Invoke persis.p persistently */
ASSIGN
  hCall:CALL-NAME  = "persis.p"
  /* Sets CALL-TYPE to the default */
  hCall:CALL-TYPE  = PROCEDURE-CALL-TYPE
  hCall:PERSISTENT = TRUE.

hCall:INVOKE.

/* Invoke internal-persis-proc in persis.p */
ASSIGN
  hCall:CALL-NAME      = "internal-persis-proc"
  /* Sets CALL-TYPE to the default */
  hCall:CALL-TYPE      = PROCEDURE-CALL-TYPE
  hCall:NUM-PARAMETERS = 1.

hCall:SET-PARAMETER(1, "INTEGER", "INPUT", 333).
hCall:INVOKE( ).

/* Clean up */
DELETE PROCEDURE hCall:IN-HANDLE.
DELETE OBJECT hCall.
When persis.p is invoked dynamically, the handle of the running persistent procedure is stored automatically in the call object's IN-HANDLE attribute. When internal-persis-proc is invoked dynamically, ABL knows it resides in the running persistent procedure whose handle is stored in the call object's IN-HANDLE attribute.
You can also run a procedure persistently by setting the PROCEDURE-TYPE attribute to "PERSISTENT". Setting the PROCEDURE-TYPE attribute to "PERSISTENT" and setting the PERSISTENT attribute to "TRUE" are equivalent, and setting one will automatically set the other. Setting the two attributes to conflicting values, e.g., PROCEDURE-TYPE to "SINGLETON" and PERSISTENT to TRUE, will cause a run-time error.