calling function

sureshp

Member
can i call a function whose name is stored as a value in another variable.

for instance

FUNCTION funName RETURNS CHAR():
RETURN "Hai".
END FUNCTION.


DEV VAR c AS CHAR.

c = "funName".
 

RKR

Member
can i call a function whose name is stored as a value in another variable.

for instance

FUNCTION funName RETURNS CHAR():
RETURN "Hai".
END FUNCTION.

DEV VAR c AS CHAR.

c = "funName".

Yes it can be done without a problem using the dynamic-function statement.

/* sample */
FUNCTION test RETURNS LOGICAL (ilValue AS LOGICAL):
RETURN ilvalue = TRUE.
END FUNCTION.

DEFINE VARIABLE cFunction AS CHARACTER NO-UNDO INITIAL "test".

MESSAGE DYNAMIC-FUNCTION(cFunction,FALSE)
VIEW-AS ALERT-BOX.

MESSAGE DYNAMIC-FUNCTION(cFunction,TRUE)
VIEW-AS ALERT-BOX.
 
Top