Home icon
Home

CLEAR Command

Purpose:

To set all numeric variables to zero, all string variables to null, and to close all open files. Options set the end of memory and reserve the amount of string and stack space available for use by GW-BASIC.

Syntax:

CLEAR[,[expression1][,expression2]]

Comments:

expression1 is a memory location that, if specified, sets the maximum number of bytes available for use by GW-BASIC.

expression2 sets aside stack space for GW-BASIC. The default is the previous stack space size. When GW-BASIC is first executed, the stack space is set to 512 bytes, or one-eighth of the available memory, whichever is smaller. GW-BASIC allocates string space dynamically. An "Out of String Space" error occurs only if there is no free memory left for GW-BASIC to use.

The CLEAR command:

Examples:

CLEAR

Zeroes variables and nulls all strings.

CLEAR 32768

Zeroes variables, nulls strings, protects memory above 32768, does not change the stack space.

CLEAR ,,2000

Zeroes variables, nulls strings, allocates 2000 bytes for stack space, and uses all available memory in the segment.

CLEAR ,32768,2000

Zeroes variables, nulls strings, protects memory above 32768, and allocates 2000 bytes for stack space.