CLEAR

BASin

CLEAR

Statement/Command

CLEAR deletes the current values of all variables, freeing the memory space that the values occupied and space as far as RAMTOP, the top address of the BASIC system area. CLEAR may also be used to reset RAMTOP.

How to use CLEAR

CLEAR may be used as a direct command or it may form a statement in a program. It requires no parameters, for example

50 CLEAR

CLEAR then delets the values that are currently assigned to all variables, including arrays. It also executes CLS and RESTORE to clear the screen and restore the data pointer to the first item of data. In assition, the PLOT position is reset to the bottom left-hand corner of the display area and the GO SUB stack is cleared.

Note that CLEAR is not required before re-dimensioning arrays as DIM deletes an existing array of the same name. Note also that RUN executes CLEAR.

CLEAR and RAMTOP

CLEAR may also be followed by a numeric value, for example

CLEAR 65267

Clear then executes CLEAR as above and also sets RAMTOP, the highest address of the BASIC system area, to the given value. RAMTOP is normally set at 65367 in BASIC, and lies below the area reserved for user-defined graphics. NEW clears out the memory as far as RAMTOP, so using CLEAR to lower RAMTOP (by 100 bytes in the above example) provides more memory that is immune from NEW. Raising RAMTOP gives more space for BASIC at the expense of user-defined graphics. Note that the GO SUB stack is then located at RAMTOP.

The current RAMTOP address can be located by the following command

PRINT PEEK 23730+256*PEEK 23731

Format

  • CLEAR [num-expr]

See also

Chapter 24.