Kbase P88579: 4GL/ABL: When to use the DYNAMIC-FUNCTION Function?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  4/16/2008 |
|
Status: Unverified
GOAL:
4GL/ABL: When to use the DYNAMIC-FUNCTION Function?
FACT(s) (Environment):
Progress 9.x
OpenEdge 10.x
All Supported Operating Systems
FIX:
Use the DYNAMIC-FUNCTION Function to invoke a user-defined function dynamically, that is when your function name is not known until run time. In this case, Progress evaluates the name of the function (and its procedure handle, if any) at run time. Progress cannot check the mode and type of the parameters at compile time, since Progress does not evaluate function-name until run time.
For example, the following procedure defines the variable cFuntionName and passes it as the input for the DYNAMIC-FUNCTION function at run time:
DEFINE VARIABLE cFuntionName AS CHARACTER NO-UNDO.
FUNCTION getCharacter RETURNS CHARACTER FORWARD.
FUNCTION getInteger RETURNS INTEGER FORWARD.
FUNCTION getLogical RETURNS LOGICAL FORWARD.
ASSIGN
cFuntionName = "getCharacter".
MESSAGE DYNAMIC-FUNCTION(cFuntionName IN THIS-PROCEDURE)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
ASSIGN
cFuntionName = "getInteger".
MESSAGE DYNAMIC-FUNCTION(cFuntionName IN THIS-PROCEDURE)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
ASSIGN
cFuntionName = "getLogical".
MESSAGE DYNAMIC-FUNCTION(cFuntionName IN THIS-PROCEDURE)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
FUNCTION getCharacter RETURNS CHARACTER.
RETURN "First".
END.
FUNCTION getInteger RETURNS INTEGER.
RETURN 1.
END.
FUNCTION getLogical RETURNS LOGICAL.
RETURN TRUE.
END.