NEW

From BeebWiki
Jump to: navigation, search

NEW is a BASIC command to erase the current program and variables.

NEW
Availability Present in all original versions of BBC BASIC.
Syntax BASIC I-V NEW
Token (hex) BASIC I-IV CA (command)
BASIC V C7 97 (command)
Description BASIC I-V Writes an empty program at PAGE, CLEARs the BASIC heap and resets TOP, VARTOP and the DATA pointer.
Associated keywords OLD

Description

NEW erases the BASIC program currently in memory, as well as all non-resident variables, arrays and memory blocks. As a command it cannot be executed within a program.

NEW does not affect the resident integer variables A% to Z% and @%.

If NEW has been entered by mistake, the program can be recovered with OLD, provided no new programs have been LOADed, lines entered or variables declared. The old variables, however, are permanently lost.

If there is no valid program at PAGE, the user must enter NEW before trying to type in a listing, otherwise the computer may crash searching for the end of the program.

The command writes the end-of-program marker, &0D &FF (6502/32000/ARM), &00, &FF, &FF (Z80/80x86/PDP), to memory at PAGE, sets TOP = PAGE + 2 (6502/32000/ARM) or PAGE+3 (Z80/80x86/PDP) and the DATA pointer to PAGE. It then does a CLEAR, resetting the heap head pointers and setting VARTOP = LOMEM.

-- beardo 19:26, 20 March 2007 (UTC)