in BASIC ROM:
|List of all BASIC keywords|
Type: Command General Programming-Syntax: CLR
The BASIC-Command CLR deletes all variables, arrays, data read position from DATA lines, defined functions (DEF FN), return addresses of subroutines (GOSUB) and the state of loops (FOR and NEXT) by releasing the space in BASIC RAM and on stack previously allocated for those structures. Furthermore the state of open files (OPEN) and possibly buffered data for devices like diskette or datasette of the associated files gets lost because the data is freed.
The CLR action is part of the RUN command and releases the space which has been temporarily allocated before. The use of CLR after a user break or program break (STOP) prevents the continuation of a program with CONT.
The command does not allow any parameters. In case a parameter is given the execution terminates with the BASIC error message ?SYNTAX ERROR.
10 A=64 : B$="COMMODORE" : C%=128 20 PRINT B$ A "AND " B$ C% ; FRE(0)+65536 30 CLR 40 PRINT : PRINT B$ A "AND " B$ C% ; FRE(0)+65536
0 POKE 56,52: CLR: REM make some free space after the BASIC program area for sprite, character or sound data 10 A$="" : REM the above usage of the CLR command MUST precede the first variable usage 20 POKE 13312,8 : REM this would be dangerous if the BASIC program area was not limited in line 0 or CLR was omitted - program code could be overwritten