Sinclair BASIC
Encyclopedia : S : SI : SIN : Sinclair BASIC
Sinclair BASIC (taking its name from innovator Sir Clive Sinclair) is a dialect of the BASIC programming language used in the 8-bit home computers from Sinclair Research and Timex Sinclair. The Sinclair BASIC interpreter was made by Nine Tiles Networks Ltd.
Originally developed in 1979 to fit in the 4 KB ROM of the ZX80, it was initially an incomplete implementation of the 1978 ANSI minimal BASIC standard and evolved through the 8K ROM ZX81 and TS1000 to be an almost complete version in the 16K ROM ZX Spectrum.
Original Sinclair BASIC
The larger upper portion of the screen shows a portion of the currently loaded program, 3D Monster Maze. The currently selected line is marked with the "program cursor", the inverse greater than sign. The lower portion of the screen shows the current version of the edited line in the line-oriented editor buffer. The current insert position is marked with the inverse letter cursor; the letter L signifies that the keyboard is in the ordinary letter input mode. The user has just changed the busy-waiting loop upper limit to the minimum, as per the original game instructions, to maximize the in-game speed; hitting ENTER will commit the change.
Reserved words
On the Spectrum there are 86 reserved words in Sinclair BASIC, denoting commands (50), functions (31), and other keywords (5):
- ABS, ACS, AND1, ASN, AT, ATN, ATTR, BEEP, BIN, BORDER, BRIGHT, CAT2, CHR$3, CIRCLE, CLEAR, CLOSE#2, CLS, CODE3, CONTINUE, COPY, COS, DATA, DEF FN, DIM, DRAW, ERASE2, EXP, FLASH, FN, FOR, FORMAT2, GO SUB, GO TO, IF4, IN, INK, INKEY$3, INPUT, INT, INVERSE, LEN, LET5, LINE, LIST, LLIST, LN, LOAD, LPRINT, MERGE, MOVE2, NEW, NEXT, NOT1, OPEN#2, OR1, OUT, OVER, PAPER, PAUSE, PEEK, PI, PLOT, POINT, POKE, PRINT, RANDOMIZE, READ, REM, RESTORE, RETURN, RND, RUN, SAVE, SCREEN$3, SGN, SIN, SQR, STEP, STR$3, TAB, TAN, THEN 4, TO, USR, VAL3, 6, VAL$3, VERIFY
- FAST, SCROLL, SLOW, UNPLOT, GOSUB, GOTO (vs the Spectrum's GO SUB, GO TO)
- PLAY, SPECTRUM
Notes
- The AND, NOT, and OR functions are logical operators.
- CAT, CLOSE#, ERASE, FORMAT, MOVE, and OPEN# are ZX Microdrive file system commands, whose attempted use without a Microdrive produces an error.
- String variable names must consist of only one alphabetical character.
Thus, «LET A=5», «LET Apples=5», and «LET A$="Hello"» are all good, while «LET APPLES$="Fruit"» is not. - There is no ELSE operator in the IF–THEN(–ELSE) clause.
Thus, instead of
10 IF V=5 THEN GO TO 50 ELSE GO TO 100
it is
10 IF V=5 THEN GO TO 50
20 GO TO 100 - LET is compulsory (i.e., «LET A=1» but never «A=1»); a practice different from most other BASIC dialects.
- The VAL function does not just evaluate numbers but full expressions. For example, «PRINT VAL(A$)» will output 14 when given an A$ of "3*3+4+COS(0)".
Timex BASIC
The Timex BASIC dialect, used on the Spectrum-compatible TS2068, but not the TS2048, which used the ordinary Sinclair BASIC, has the following six keywords as well as the ordinary Sinclair BASIC ones:
- DELETE, FREE, ON ERR, RESET, SOUND, STICK
Extensions and variants
- Beta BASIC, written by Dr. Andy Wright, was originally a BASIC extension, but ended up as a full-fledged interpreter.
- Sinclair Extended BASIC is an ongoing retrocomputing project aiming for an improved version of Sinclair BASIC (beta versions available as of July 2005).
References
- Vickers, Steven (1982). Sinclar ZX Spectrum BASIC Programming. Sinclair Research.
- Ardley, Neil (1984). Sinclair ZX Spectrum+ User Guide. Dorling Kindersley in association with Sinclair Research. ISBN 0-86318-080-9.
External links
- [Sinclar ZX Spectrum BASIC Programming] – The original 1982 manual by Steven Vickers (referenced above)
- [The History of Sinclair BASIC] – By Andrew Owen, whose Sinclair BASIC documents are hosted by the World of Spectrum website
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
