Chapter
10
I
BASIC
Ke-ywords
CLEAR
Statement
CLEAR
[,memory location.]
[,stack
space][,uideo
memory1
Frees memory
for
data without erasing the program currently in
memory. CLEAR erases all
arrays,
sets numeric variables
to
zero and string variables to null, and erases any information set
using a DEF statement, such as DEF SEG and DEF FN.
CLEAR also turns
off
the SOUND, PEN, and STRIG functions
and resets the music background.
Since CLEAR initializes all variables, place it near the begin-
ning
of
your program, before any variables have been defined
and before any DEF statements.
Memory
location
must be an integer. It specifies the highest
memory location available
for
BASIC. The default is the current
top
of
memory
as
specified with the
/M:
switch when BASIC was
loaded. This option is useful if you will be loading an assembly-
language subroutine, because it prevents BASIC from using that
memory area.
Stack
space
also must be an integer. This sets aside memory
for
temporarily storing internal data and addresses during subrou-
tine calls and during FOR/NEXT loops. If you omit
stack
space,
BASIC sets aside
768
bytes
or
one-eighth
of
the memory avail-
able, whichever is smaller. BASIC displays an “Out
of
memory”
error if stack space
for
program execution is insufficient.
Video
memory
is an integer that specifies the amount
of
memory
to be set aside
as
video memory. For graphics modes, if the
vdeo
memory
you specify is not a multiple
of
16K
bytes
(16384
bytes),
BASIC rounds it down to the nearest multiple
of
16K.
If you
omit
video
memory,
BASIC sets aside
16K.
The video memory
page size for each screen mode
is
described
in
Chapter
8,
“Dis-
playing Color and Graphics.”
117