Functions and Directives

Function IsFieldVar() Foundation

Checks if a symbolic name indicates a field variable

IsFieldVar( <cVarName> ) --> lExist
<cVarName> is a character string containing the symbolic identifier of a field variable.
Optionally, the symbolic identifier can be qualified with the alias name of the work area to be searched ("ALIAS->FIELDNAME"). Without alias name, <cVarName> is only searched in the current work area.

The function returns .T. (true) if a field variable with the name <cVarName> exists, otherwise it returns .F. (false).


The function IsFieldVar() checks whether or not a character string matches the name of a field variable. If this is the case, the field variable can be accessed or changed using the macro operator. However, when using the macro operator it must be guaranteed that no dynamic memory variable with the name <cVarName> exists at the same time. Otherwise, IsFieldVar() may return .T. but the expression &cVarName may return the value of a memory variable rather than the field variable's value. This depends on the compiler switch /v.

The existence of a field variable can also be checked with the function FieldPos().

Test if a field variable exists

// The example shows two possibilities to test 
// whether or not a field variable exists. 

   LOCAL cVarname := "Lastname" 

   USE Customer 

   IF IsFieldVar( cVarname ) 
      ? FIELD->&cVarname          // result: Miller 

   IF FieldPos( cVarname ) > 0    // alternative for IsFieldVar() 
      ? FIELD->&cVarname 



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.