Sinclair BASIC

Sinclair BASIC is a dialect of the programming language BASIC used in the 8-bit home computers from Sinclair Research and Timex Sinclair. The Sinclair BASIC interpreter was made by Nine Tiles Networks Ltd.
History.
Sinclair BASIC was originally developed in 1979 for the ZX80 by Nine Tiles. The programmers were John Grant, the owner of Nine Tiles, and Steve Vickers.
It was initially an incomplete implementation of the 1978 American National Standards Institute (ANSI) minimal BASIC standard with integer arithmetic only, termed the 4K BASIC (for its ROM size) for the ZX80. It evolved through the floating-point 8K BASIC for the ZX81 and TS1000 (which was also available as an upgrade for the ZX80), and became an almost complete version in the 16 KB ROM ZX Spectrum. It is present in all ZX Spectrum compatibles.
As of 2015, interpreters exist for modern operating systems, and older systems, that allow Sinclair Basic to be used easily.
Syntax.
New BASIC programmers might start with a simple program, perhaps using the language's PRINT statement to display a message on the screen; a well-known and often-replicated example is Kernighan and Ritchie's Hello world program:
 10 PRINT "Hello, World!"
Keywords.
On the 16K/48K ZX Spectrum, there are 88 keywords in Sinclair BASIC, denoting commands (of which there are 50), functions and logical operators (31), and other keywords (16, including 9 which are also commands or functions):
Keyword entry.
In 48K models and older, the keywords are entered via Sinclair's unique keyword entry system, as indicated on the table. The most common commands need one keystroke only; for example, pressing only at the start of a line on a Spectrum produces the full command codice_1. Less frequent commands require more complex key sequences: codice_2 (for example) is keyed by pressing plus to access extended mode (later models include an key), keeping held down and pressing . Keywords are colour-coded on the original Spectrum keyboard to indicate which mode is required:
The ZX81 8K BASIC used the shorter forms codice_3, codice_4, codice_5 and codice_6, whereas the Spectrum used the longer forms codice_7, codice_8, codice_9 and codice_10. The ZX80 4K BASIC also used these longer forms but differed by using the spelling codice_11. The ZX81 8K BASIC was the only version to use codice_12, codice_13, codice_14 and codice_15. The ZX80 4K BASIC had the exclusive function codice_16; it was equivalent to the string operator in later versions.
Unique code points are assigned in the ZX80 character set, ZX81 character set and ZX Spectrum character set for each keyword or multi-character operator, i.e. codice_17, codice_18, codice_19, codice_20 (tokenized on the ZX81 only), codice_21 (replaced with codice_22 on the Spectrum). These are expanded by referencing a token table in ROM. Thus, a keyword uses one byte of memory only, a significant saving over traditional letter-by-letter storage. This also meant that the BASIC interpreter could quickly determine any command or function by evaluating one byte, and that the keywords need not be "reserved words" like in other BASIC dialects or other programming languages, e.g., it is allowed to define a variable named codice_1 and output its value with codice_24. This is also related to the syntax requirement that every line start with a command keyword, and pressing the one keypress for that command at the start of a line changes the editor from command mode to letter mode. Thus, variable assignment requires LET (i.e., LET a=1 not only a=1). This practice is also different from other BASIC dialects. Further, it meant that unlike other BASIC dialects, the interpreter needed no parentheses to identify functions; codice_25 was sufficient, no codice_26 needed (though the latter was allowed). The 4K BASIC ROM of the ZX80 had a short list of exceptions to this: the functions codice_27, codice_28, codice_16, codice_30, codice_31, codice_32, codice_33 and codice_34 did not have one-byte tokens but were typed in letter-by-letter and required the parentheses. They were listed as the INTEGRAL FUNCTIONS on a label above and to the right of the keyboard.
The 128K Spectrum models, the ZX Spectrum 128, +2, +3, +2A, and +2B, also stored keywords internally in one-byte code points, but used a conventional letter-by-letter BASIC input system. They also introduced two new commands:
The original Spanish ZX Spectrum 128 included four additional commands in Spanish, one of which was undocumented. These can be translated as:
Unlike the codice_41, codice_42 and codice_43 functions used in the ubiquitous Microsoft BASIC dialects for home computers, parts of strings in Sinclair BASIC are accessed by numeric range. For example, gives a substring starting with the 5th and ending with the 10th character of the variable codice_44. Thus, it is possible to replace the codice_41 and codice_43 commands by simply omitting the left or right array position respectively; for example is equivalent to codice_47. Further, codice_48 alone is enough to replace codice_49.
Variable names.
Variables holding numeric values may be any length, while string and array variable names must consist of only one alphabetical character. Thus, LET a=5, LET Apples=5, LET a$="Hello", DIM a(10) and DIM a$(10) are all good, while LET Apples$="Fruit", DIM Apples(10) and DIM Apples$(10) are not.
The long variable names allowed for numeric variables can include alphanumeric characters after the first character, so LET a0=5 is allowed but not LET 0a=5. The long variable names can also include spaces, which are ignored, so LET number of apples = 5 is the same as LET numberofapples = 5
Other versions, extensions, derivatives and successors.
Interpreters for the ZX Spectrum family.
Several ZX Spectrum interpreters exist.
Compilers for the ZX Spectrum family.
Several ZX Spectrum compilers exist.