Directives 

CLEAR

Reset Variables

Formats

1. Clear, Reset:

CLEAR[ *] [ [ EXCEPT ] varlist ]

2. Clear Composite String:

CLEAR template$

Where:

template$

Name of a variable DIMensioned as a string template. String expression. 

varlist

An optional list of variables.

Description

The CLEAR directive performs the following functions:

     1. Resets PRECISION to the default value of 2 (the value set in the 'PD' system parameter).

     2. Clears local variables. (Global variables are not affected unless using CLEAR *) 

(a) All variables if no varlist appears on directive.
(b) Only those in varlist if no EXCEPT clause given.
(c) All but those in varlist if EXCEPT clause present.

See Example.

     3. Sets ERR, RET and CTL to zero. 

     4. Clears FOR/NEXT, GOSUB/RETURN, WHILE/WEND, etc. stack.

The CLEAR * directive also clears all global variables including those defined using the GBL function. CLEAR * will also accept an EXCEPT varlist clause to omit specific variables from being cleared.

Note:
When executed within an object (in Object Oriented Programming), the CLEAR directive will clear all of the object's properties, along with standard variables.

(The CLEAR * directive was added in PxPlus v7.10.)

Format 1

Clear, Reset

CLEAR [EXCEPT] [varlist

Example:

The following examples show respectively clearing all variables, clearing only a selected list of variables, and CLEARing all EXCEPT a selected list of variables:

clear
clear A3$,B3$,C3,D3
clear except CST_ID$,TX_VAL,TX_TBL${all}

Format 2

Clear Composite String

Use this format to clear the value(s) DIMensioned as a string template:

clear CUST$

or

clear CUST.NAME$

For information on string templates, see DIM Define Arrays and Strings.

See Also

BEGIN Reset Files and Variables
RESET Reset Program State
START Restart Session
ERR( ) Test Error Value
CTL Control Code: Key to End Input
RET Operating System's Last Error Code