Name: CLEAR Shortest: CLE
Family: Command Category: Programming
Description: Use the CLEAR command to remove global variables from memory.

Syntax

CLEAR syntax diagram

Options

ALL VARIABLES
Removes all global variables from memory. Do not use this option to clear variables in an Application Express custom command block, because several variables generated by Application Express should not be cleared until you exit the application.

EXCEPT varlist
Specifies variables that the CLEAR command will not remove. You can use wildcards in variable names.

VARIABLES varlist
Removes a list of one or more variables. Use this option at the end of a complete set of procedures to clear variables that are no longer needed. You can use wildcards in variable names.

About the CLEAR Command

When R:BASE is first loaded into memory, only system variables are defined; they are not affected by the CLEAR command. Variables defined in reports are cleared automatically after the report is printed. Other variables you define remain in memory until you exit from R:BASE or use the CLEAR command.

Examples

The following command removes the global variables vcounter and vname from memory.

CLEAR VARIABLES vcounter, vname

The following command removes all global variables from memory.

CLEAR ALL VARIABLES

The following command removes all global variables except var1.

CLEAR ALL VARIABLES EXCEPT var1

The following command clears all variables beginning with the letter v.

CLEAR VARIABLES v%

CLEAR ALL VAR NOW

CLEAR ALL VAR NOW, the fourth argument to the CLEAR ALL VAR command clears all the variable storage blocks (VSBs), including all printer control code variables and other non-permanent system variables (NPSVs). It re-allocates the blocks with just the permanent system variables (PSVs), #DATE, #TIME, #PI and SQLCODE.

Without the fourth parameter, printer control code variables and other # variables are NOT cleared. Also, it does not completely re-initialize the memory blocks as does the CLEAR ALL VAR NOW.