Functions and Directives

Function IsFunction() Foundation

Checks if a symbolic name indicates the name of a function or procedure

Syntax
IsFunction( <cFuncName>, [<nType>] ) --> lExist
Parameters
<cFuncName>
<cFuncName> is a character string containing the symbolic identifier of a function or procedure. The string must not contain parentheses.
<nType>
The #define constant FUNC_CLASS from MEMVAR.CH can be specified for <nType>. In this case, IsFunction() checks if <cFuncName>indicates a class function.
Return

IsFunction() returns .T. (true) if a function or procedure with the name <cFuncName> exists, otherwise it returns .F. (false).

Description

The function IsFunction() checks if a function or procedure exists at runtime. IsFunction() differs from the function Type() by searching for a symbolic name in the symbol table, while Type() returns the data type of a macro-compiled character expression.

If functions are contained in dynamically loaded DLL files and the DLL is loaded with a function prefix specified to DllLoad(), the parameter <cFuncName> must contain this prefix when testing the existence of DLL functions.

Examples
Test if a function exists

// The example demonstrates the difference between 
// IsFunction() and Type(). 

PROCEDURE Main 
   LOCAL cSymbol := "Date", cExpression := "Date()" 

   ? IsFunction( cSymbol )           // result: .T. 
   ? Type( cExpression )             // result: D 

   cSymbol     := "AAdd" 
   cExpression := "AAdd()" 

   ? IsFunction( cSymbol )           // result: .T. 
   ? Type( cExpression )             // result: UE, syntax error 

RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.