Use the Spectrum 128 style menu below to navigate to the various sections detailing the Extended BASIC mechanism.

128 Extended BASIC Main Menu Title
Method of Operation
Extension Framework
Example Commands


Example Commands

To demonstrate the Extended BASIC Framework, I've produced a number of example commands to show how to use it features. The commands are designed to provide examples of different types of functionality, e.g. reading from a variable, writing to a variable, writing to the screen, supporting optional parameters, etc. The commands are as follows:

Command Description
COMMANDS Displays a list of all new extended BASIC commands.
VERSION Displays version number information for the Extended BASIC Framework and the user implemented commands.
DISABLE Disables the new framework, useful to allow access to the RS232 commands. Use USR 65040 to re-enable the parser afterwards.
MODEL Displays the model of 128K Spectrum detected, or stores a enumeration value or string in the specified variable.
BANNER Displays at the specified or current screen coordinates a Spectrum 128 style banner.
SCROLL Scrolls the screen up a specified number of times.
CAT ATTR ! Displays a more detailed catalogue of the RAM disk, including the attributes associated with each file.
ERASE CAT ! Erases the entire catalogue of files from the RAM disk.
RENAME ! Renames a RAM disk file.
GO STATEMENT Performs a GO TO except it allows a particular statement number with a line to be specified.
REMOVE Removes the specified variable from memory.
TRIM LEFT Removes the leading spaces from the specified string variable.
TRIM RIGHT Removes the trailing spaces from the specified string variable.
TRIM Removes the leading and trailing spaces from the specified string variable.
TO UPPER Converts the contents of a string variable into upper case.
TO LOWER Converts the contents of a string variable into lower case.
TO TITLE Converts the contents of a string variable into title case, i.e. only the first letter of each word is in upper case.
CLS RESTORE Clears the screen, restoring the permanent colours back to black ink on white paper.
RENUMBER Renumbers the BASIC program, with specified start line number and line increment.
DELETE Deletes a specified block of lines from the BASIC program.
WIDTH Sets the number of columns per row for the RS232 printer routines.

Click here to download the assembled Extended BASIC Framework containing the example commands.
Click here to download the assembled Extended BASIC Framework (with ZX Interface 1 support) containing the example commands.
Click here to download the Extended BASIC Framework source code containing the example commands.

To use the assembled Extended BASIC Framework, execute the following commands:

  CLEAR 39999
  LOAD "" CODE 40000
  USR 40000

This will install the framework, enable the extended BASIC parser, and remove the installer from memory thereby setting RAMTOP for maximum available RAM. The version numbers of the framework and application are then displayed.

Extended BASIC Framework Screenshot

The version number for the standard Extended BASIC Framework has suffix 'A', whereas the build that includes support for the ZX Interface 1 suffix 'B'.

The screenshots below show an example use of some of the new commands.

Extended BASIC Framework Example - Listing Screenshot
Extended BASIC Framework Example - Output Screenshot

Below is a description of each of the new commands, showing their usage and any supported parameters.

COMMANDS Command
Displays a list of all new Extended BASIC commands.

Usage: COMMANDS

DISABLE Command
Disables the new command parser. This is useful to allow access to the RS232 commands, which cannot be used whilst the new parser is enabled. After executing the RS232 commands, the extended BASIC parser can be re-enabled via USR 65040.

Usage: DISABLE

VERSION Command
Displays Extended BASIC Parser and user application version number information.

Usage: VERSION

MODEL Command
Prints to the screen at the current display coordinates the model of 128K Spectrum detected, or stores the string in the specified string variable, or store an enumeration value identifying the model in the specified numeric variable. Model enumeration values and strings are as follows:

0 = Spectrum 128 (UK).
1 = Spectrum 128 (Spanish).
2 = Spectrum +2 (UK).
3 = Spectrum +2 (Spanish).
4 = Spectrum +2 (French).
5 = Unknown.

Usage: MODEL
MODEL n where n is the numeric variable to store the model enumeration value in.
MODEL n$ where n$ is the string variable to store the model text in.

BANNER Command
Prints to the screen at the current display coordinates a Spectrum 128 style banner. Although the UK 128 and all +2 models include routines in their ROM 0 to print such a banner, the Spanish 128 does not. Also, the position of the banner displayed by the ROM is fixed at row 21, where as this command allows the banner to be displayed on any row.

Usage: BANNER n$ where n$ represents the string to print (string variable or literal).
BANNER AT n; n$ where n is the row to print the banner on and n$ represents the string to print (string variable or literal).

SCROLL Command
Scroll the screen up a specified number of times.

Usage: SCROLL
SCROLL n where n is the number of times to scroll up (1-24).

CAT ATTR ! Command
This command produces a more detailed catalogue listing of the RAM disk, displaying to the screen the attributes associated with each file. The files are displayed in the order in which they are stored.

Usage: CAT ATTR !

ERASE CAT ! Command
This command erases the entire catalogue of all files from the RAM disk.

Usage: ERASE CAT !

RENAME ! Command
This command renames a RAM disk file.

Usage: RENAME ! n$, m$ where n$ represents the original file name (string variable or literal) and m$ the new file name (string variable or literal).

GO STATEMENT Command
This command is similar to GO TO except it allows a particular statement number with a line to be specified.

Usage: GO STATEMENT n, m where n is the line number to jump to and m is the statement number (1 being the first statement).

REMOVE Command
This command removes the specified variable from memory.

Usage: REMOVE n where n represents any variable. For arrays, do not specify subscripts, e.g. use n().

TRIM LEFT Command
This command removes the leading spaces from the specified simple string variable.

Usage: TRIM LEFT n$ where n$ represents any simple string variable.

TRIM RIGHT Command
This command removes the trailing spaces from the specified simple string variable.

Usage: TRIM RIGHT n$ where n$ represents any simple string variable.

TRIM Command
This command removes the leading and trailing spaces from the specified simple string variable.

Usage: TRIM n$ where n$ represents any simple string variable.

TO UPPER Command
This command converts the contents of a string variable into upper case.

Usage: TO UPPER n$ where n$ represents any string variable.

TO LOWER Command
This command converts the contents of a string variable into lower case.

Usage: TO LOWER n$ where n$ represents any string variable.

TO TITLE Command
This command converts the contents of a string variable into title case, i.e. only the first letter of each word is in upper case.

Usage: TO TITLE n$ where n$ represents any string variable.

CLS RESTORE Command
This command performs an identical function to the new CLS # command introduced by the ZX Interface 1, restoring the permanent screen colours back to black ink on white paper. It could have been named CLS # as per the ZX Interface 1 command but since the '#' character is used by Sinclair BASIC to refer to a stream, its use with CLS is inconsistent and hence the keyword RESTORE has been used here instead. Note that since this is an extension of a standard command, the standard ROM command handler will be executed first before the extended BASIC parser provides the new functionality. This effectively results in the screen being cleared twice, the first using the current colours and the second time with the restored colours.

Usage: CLS RESTORE

RENUMBER Command
Renumber the BASIC program, with specified start line number and line increment. Although this command can be run from within a program, it will stop the program after the command has completed. To overcome a bug in the ROM 0 Renumber routine, it is necessary for this command to clear the variables area before renumbering occurs.

Usage: RENUMBER using default new start line number of 10 and default line increment of 10.
RENUMBER n1 where n1 represents the new start line number and default line increment of 10.
RENUMBER n1, n2 where n1 represents the new start line number and n2 represents the line increment.

DELETE Command
Delete a block of lines from the BASIC program. Although this command can be run from within a program, it will stop the program after the command has completed.

Usage: DELETE n1, n2 where n1 the lower line number (inclusive) and n2 the upper line number (inclusive) of the block to delete.

WIDTH Command
Sets the number of columns per row for the RS232 printer routines.

Usage: WIDTH restores the default column width of 80.
WIDTH n1 where n1 is the new number of columns per row.