Are you frustrated with ZX BASIC's limited editing features?
Do you often reach for BASIC extenders or toolkits? Are you,
for similar reasons, using a modified ZX BASIC ROM and
occasionally having to figure out whether and how it is
compatible with the original, or why some program does not
work with it?

Try a different approach: use esxDOS, which offers system
commands with a range of new features. Exactly the ones you
were missing and had to work around with non-standard ROM
patches or memory-consuming extensions. With modern esxDOS
you lose not a single byte of standard memory and you are
guaranteed full compatibility with the original ROM.

esxDOS extensions are available at esxdos.zxfiles.net.

------------------------------------------------------------
.DEL command for esxDOS                                 2026
------------------------------------------------------------

.DEL is a so-called dot command, stored in the BIN directory
on the SD card and launched from the ZX Spectrum BASIC edit
line. It does one simple thing - it deletes lines of a BASIC
program. It is similar to the standard editor line deletion,
except it can do it in bulk - with one command it removes an
entire range, or for example every other line from X to Y.
Where you would have to type individual line numbers and
press ENTER in the editor, you now type .DEL 100 200 and
you are done.

.DEL behaves exactly as if the BASIC editor itself were
doing the work: it locates the line address by number,
advances to the next program line, deletes bytes from
memory, and after the deletion adjusts all system pointers
(VARS, E-LINE, STKBOT, STKEND, etc.).


What happens when you specify a line not in the program?
------------------------------------------------------------
The rule for .DEL is: the boundary lines you specify do not
need to exist in the program. The command finds what is
available on its own. If you type .DEL 100 200 and the
program contains lines 50, 150 and 250, line 150 is deleted
and lines 50 and 250 remain. If you type .DEL 9000 and the
highest line in the program is 500, it returns
"No lines in given range".


Command syntax
------------------------------------------------------------
The command understands two conventions that can be mixed.

1. Parameters separated by comma or semicolon (both have
the same meaning). Spaces instead of or in addition to the
separator work the same way, so there is no difference
between .DEL 100 200 5 and .DEL 100,200;5.

2. Token notation: .DEL <first> TO <last> STEP <step>
Just as in BASIC, the keywords TO and STEP are entered from
the keyboard using SYMB+F and SYMB+D. If you type them as
two or four letters, the parser will not recognise them and
will report an error - a genuine BASIC token is required.

Both styles can be combined: .DEL 100 TO 200,5 is legal,
as is .DEL 100,200 STEP 5. Values are always interpreted
by position or token. Without TO and STEP, the first number
is <first>, the second is <last>, the third is <step>.


Separators - they can fill in a missing value
------------------------------------------------------------
Here .DEL tries to be smart. If you omit a parameter before
a comma or semicolon, the command substitutes a sensible
default - the number of the first or last line in the
program.

The fill-in rules are:
a) empty slot before the first separator - first is replaced
   by the number of the first existing line in the program
b) empty slot before the second separator - last is replaced
   by the number of the last existing line

A few concrete examples:
.DEL ;40         deletes from the first line up to 40,
.DEL 100,        deletes from 100 to the end of the program,
.DEL ,           entire program (start=first, end=last),

If you type .DEL N with nothing else, only line N is
deleted. .DEL 100 and .DEL 100, therefore behave
differently. Without a separator, end is implicitly equal
to start; with any separator (even just a trailing comma),
end implicitly means "to the end".


Step (STEP / third positional number)
------------------------------------------------------------
When a step is specified, the command switches from
contiguous deletion to "striped" deletion. Instead of
cutting one block at once, it walks through the range line
by line and deletes only those whose position within the
range matches the step. The step must be in the range 1 to
16382. Step 1 gives the same result as contiguous mode.

.DEL ,40 STEP 5  every line with increment five from the
                   start of the program up to 40,
.DEL 100,;2      every line (+2) from 100 to the end,
.DEL ,,2         every line (+2) of the entire program.


Test mode (-n as no-op, no-operation)
------------------------------------------------------------
If you insert the switch -n (or -N) between .DEL and the
parameters, the command deletes nothing and only counts how
many lines it would delete if run for real. It then reports
the result with the message "Would delete ..lines". So
before actual deletion you can see what is coming :-)


Line number range
------------------------------------------------------------
Line zero is usually created via POKE. .DEL 0 lets you
easily get rid of it.

A line number in BASIC memory can be stored in the range 0
to 16383. Standard Sinclair ROM BASIC allows entering (and
displaying) only lines 0 to 9999. Some later ROM patches
lifted this restriction and use the full range up to 16383.
.DEL was written to work with the maximum range. It accepts
and validates the full range 0 to 16383. The message "Line
out of range" therefore refers to this upper bound. The
actual line number limit is determined by the BASIC ROM
with which esxDOS runs.


Error messages
------------------------------------------------------------
If you run .DEL without arguments, you get a short help
listing.

If you type something nonsensical, i.e. a character appears
in the parameters where it does not belong (a letter where
a number is expected, an unknown token, a duplicate TO, a
fourth positional argument, etc.), the command returns with
the authentic Sinclair message "Nonsense in BASIC" - the
same message BASIC would print if you typed LET 5 = ABC.

New messages are:

  Line out of range (0..16383) - a number exceeds the
                                 14-bit range,
  Step out of range (1..16382) - invalid step value,
  Bad range: end before start  - end is less than start,
  No lines in given range      - the range is formally
                                 valid but contains not
                                 a single existing line
                                 (or the program is empty).


What .DEL does not do and cannot do
------------------------------------------------------------
* It does not delete BASIC variables and does not touch
  anything outside SYSVARS and the program (the area from
  PROG to VARS).
* It does not use RAMTOP or the file system buffer.
* It does not use any memory in the ZX area; it works
  exclusively with ZX Spectrum BASIC system variables.
* It does not remember previous commands and has no undo -
  a deleted line is truly gone for .DEL forever.
* If you are working with a hexadecimal line number, you
  must convert it to decimal yourself before passing it
  to .DEL.


<end>
esxDOS, with love...