Clear – Remote Processing CAMBASIC User Manual

Page 49

Advertising
background image

Comm ands - 16

CLEAR

Statement

SYNTAX:

CLEAR [ string space]

PURPOSE:

To set all numeric variables to zero, set all string variables to null, restore the data pointer, and
negate all DIM statements. You can optionally set the string space size.

REMARK S:

If the optional parameter string space is specified, variables are cleared and the string space is made
equal to the number of bytes specified. 100 bytes is the default value on power– up. You can figure
the amou nt of string spa ce by adding up the num ber of ch aracter s you expec t each string variable to
use and add the length of the longest string you will use. Then add 10% to that total. For example,
if you expect A$ to hold 75 characters and B$ to hold 45, you would need (45 + 75 + 75) x 1.1 =
215. F or safety, you should round up to the next 100.

NOTE: Make sure you execute C LEA R befor e you execu te any DI M statem ent.

Execute this statement if your program uses a large numbe r of string variables for storage or
manipulation. You will get a <Out of string space> error if there is not enough space set

aside.

RELATED:

none

EXAMPLE:

The following clear s all variables and sets the string space to 100 b ytes:

10 CLEAR

The following clear s all variables and reser ves 500 bytes of RAM for strings:

10 CLEAR 500

ERROR:

< Data negative> – for string
< Out of m emor y> – if an attemp t is made to cle ar m ore m emor y than is available
< Out of string space> -when not enough string space is reserved.

Advertising