CLEAR VARIABLE

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 3


CLEAR VARIABLE (variable)

ParameterTypeDescription
variableVariableVariable to clear

Description

This command acts differently in interpreted mode and in compiled mode.

In interpreted mode

CLEAR VARIABLE erases variable from memory. Consequently, the variable becomes undefined; trying to read its value will generate a syntax error. Note that if you again assign a value to the variable, 4D recreates the variable on the fly. After a variable is cleared, Undefined returns True when applied to that variable.

In compiled mode

CLEAR VARIABLE only resets variable to its default type value (i.e., empty string for String and Text variables, 0 for numeric variables, no elements for arrays, etc.). The variable still exists—variables can never be undefined in compiled code.

The variable you pass in variable must be a process or an interprocess variable.

Note: You do not need to clear process variables when a process ends; 4D clears them automatically.

Local variables, which are variables preceded by a dollar sign ($), cannot be cleared with CLEAR VARIABLE. They are cleared automatically when the method in which are located completes execution.

Example

In a form, you are using the drop-down list asMyDropDown whose sole purpose is user interface. In other words, you use that array during data entry, but once you are done with the form, you will no longer use that array. Consequently, during the On Unload event, you just get rid of the array:

      ` asMyDropDown drop-drop list object method
   Case of
      : (Form event=On Load)
            ` Initialize the array one way or another
         ARRAY STRING(63;asMyDropDown;...)
            ` ...
      : (Form event=On Unload)
            ` No longer need the array
         CLEAR VARIABLE (asMyDropDown)
            ` ...
   End case

See Also

Undefined.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next