Previous Next

DYNAMIC-FUNCTION function
Invokes a user-defined function. The AVM evaluates the name of the function (and the procedure handle, if any) at run time.
Syntax 
 
DYNAMIC-FUNCTION
  ( function-name [ IN proc-handle ] 
    [ , param1 [ , param2 ] ... ]
  )
function-name
A CHARACTER expression that returns the name of a user-defined function. The AVM evaluates function-name at run time.
IN proc-handle
An expression that returns a handle to the procedure that defines the function. The AVM evaluates proc-handle at run time.
param1, param2, ...
Parameters of the user-defined function. You must supply names of actual data items—actual parameter names—not CHARACTER expressions that return parameter names.
Note:
Example 
The following procedure demonstrates the DYNAMIC-FUNCTION function:
 
/* Requires a connection to the Sports2000 database. Define data items */
DEFINE VARIABLE funcs   AS CHARACTER NO-UNDO EXTENT 5 
  INITIAL ["firstrec","lastrec","nextrec","prevrec","quitting"].
DEFINE VARIABLE action  AS CHARACTER NO-UNDO LABEL "Action" FORMAT "x" 
  INITIAL "N".
DEFINE VARIABLE idx     AS INTEGER   NO-UNDO.
DEFINE VARIABLE alldone AS LOGICAL   NO-UNDO.
 
FORM WITH FRAME x SIDE-LABELS 2 COLUMNS 1 DOWN COLUMN 25.
 
/* Define user-defined functions */
FUNCTION dispcust RETURNS LOGICAL:
  DISPLAY Customer EXCEPT Customer.Comments WITH FRAME x.
END.
 
FUNCTION firstrec RETURNS LOGICAL:
  FIND FIRST Customer.
  dispcust().
  RETURN yes.
END.
 
FUNCTION lastrec RETURNS LOGICAL:
  FIND LAST Customer.
  dispcust().
  RETURN yes.
END.
 
FUNCTION nextrec RETURNS LOGICAL:
  FIND NEXT Customer NO-ERROR.
  IF AVAILABLE Customer THEN
     dispcust().
  RETURN AVAILABLE(Customer).
END.
 
FUNCTION prevrec RETURNS LOGICAL:
  FIND PREV Customer NO-ERROR.
  IF AVAILABLE Customer THEN
     dispcust().
  RETURN AVAILABLE(Customer).
END.
 
FUNCTION quitting RETURNS LOGICAL:
  alldone = yes.
  RETURN no.
END
 
/* Main routine */
REPEAT WHILE NOT alldone:
  UPDATE action HELP 
    "Enter F(irst), L(ast), N(ext), P(rior), or Q(uit) to navigate.".
  idx = LOOKUP(action,"f,l,n,p,q").
  IF idx EQ 0 THEN DO:
    MESSAGE "Enter F(irst), L(ast), N(ext), P(rior), or Q(uit)" 
      VIEW-AS ALERT-BOX.
    NEXT.
  END.
  DISPLAY DYNAMIC-FUNCTION(funcs[idx]) LABEL "Record Found?".
END.
See also 
FUNCTION statement

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.