BLOCK DELETE
by Richard Dickens
from Sinclair Answers #1 (1984)

One of the many omissions in the Spectrum Basic development
system is the facility to delete a range of lines - so here
is a short routine to get you started.

To produce the machine code routine, type in the loader
program as listed and then run it. The loader program can be
used on both 16K and 48K machines because it loads the
routine relative to RAMTOP, the last byte of basic program
space. If the loader runs OK, then a message will be
produced which tells you the calling address of the routine.

In a standard machine this will be 65314 on the 48K, and
32546 on the 16K. If you have any other machine code
routines loaded, then this may be different - write it down!

If an error message is produced, then there is an error in
the data statements, and these must be checked before
re-running. After running the loader you can save the
routine by typing SAVE "blockdel" CODE [calladdr],55; where
calladdr is the value printed by the loader program.

It might also be useful to save a small program such as:

10 CLEAR [calladdr]-1
20 LOAD "blockdel" CODE

... on the tape using the command SAVE "lodbd" LINE 10
before the machine code routine to autoload it.

To execute the routine you type

PRINT USR [calladdr],first,last

where 'first' is the first line to be deleted, and 'last' is
the last. For example,

PRINT USR [calladdr],20,100

will delete all lines from 20 to 100 inclusive.

If the first line does not exist, then the first one greater
than 'first' will be the first deleted, and if the last line
doesn't exist then the first line below 'last' will be the
last deleted.

After typing this line one of four events will occur: the
message "Nonsense in Basic" is printed - the routine was
called without any line numbers; the other three [sic. JG.]
return values are: '0', meaning that the first line number
was invalid, either too large or non numeric; and '2', which
means that the last number was invalid.

The routine works by making calls to four routines within
the Basic ROM. The first call gets the two values from the
command line and puts them onto the calculator stack. The
next call is to a routine which fetches a value from the
stack, which is passed to a routine to find the address of
this Basic line. Having done this for both line numbers, the
routine to recover space is called with the two addresses as
parameters.


--
Another Fine Product transcribed by:
Jim Grimwood (jimg@globalnet.co.uk), Weardale, England
--
