Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Sinclair BASIC
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Keyword details=== The ZX81 '''8K BASIC''' used the shorter forms <code>GOTO</code>, <code>GOSUB</code>, <code>CONT</code> and <code>RAND</code>, whereas the Spectrum '''48 BASIC''' used the longer forms <code>GO TO</code>, <code>GO SUB</code>, <code>CONTINUE</code> and <code>RANDOMIZE</code>. The ZX80 '''4K BASIC''' also used these longer forms but differed by using the spelling <code>RANDOMISE</code>. The ZX81 '''8K BASIC''' was the only version to use <code>FAST</code>, <code>SCROLL</code>, <code>SLOW</code> and <code>UNPLOT</code>. The ZX80 '''4K BASIC''' had the exclusive function <code>TL$()</code>; it was equivalent to the string operator {{nowrap|<code>(2 TO )</code>}} 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. <code><=</code>, <code> >=</code>, <code><></code>, <code>""</code> (tokenized on the ZX81 only), <code>**</code> (replaced with <code>↑</code> 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 <code>PRINT</code> and output its value with <code>PRINT PRINT</code>. 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 <syntaxhighlight lang="basic" inline>LET</syntaxhighlight> (i.e., <syntaxhighlight lang="basic" inline>LET A=1</syntaxhighlight> not only <syntaxhighlight lang="basic" inline>A=1</syntaxhighlight>). 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; <code>SIN x</code> was sufficient, no <code>SIN(x)</code> needed (though the latter was allowed). The 4K BASIC ROM of the ZX80 had a short list of exceptions to this: the functions <code>CHR$()</code>, <code>STR$()</code>, <code>TL$()</code>, <code>PEEK()</code>, <code>CODE()</code>, <code>RND()</code>, <code>USR()</code> and <code>ABS()</code> 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.<ref>{{Cite web|url=https://upload.wikimedia.org/wikipedia/commons/5/54/Sinclair_ZX80_%281980%29_-_Computer_History_Museum.jpg|title=Picture of ZX80}}</ref> '''128 BASIC''', present on ZX Spectrum 128, +2, +3, +2A, and +2B, stored keywords internally in one-byte code points, but used a conventional letter-by-letter BASIC input system. It also introduced two new commands: * <code>PLAY</code>, which operated the 128k models' [[General Instrument AY-3-8910]] music chip * <code>SPECTRUM</code>, which switched the 128k Spectrum into a 48k Spectrum compatibility mode The original Spanish ZX Spectrum 128 included four additional BASIC editor commands in Spanish,<ref name="Disassembly"/><ref>{{Cite book |last=Sinclair |url=http://archive.org/details/128_20220808_202208 |title=ZX Spectrum 128 Introducción y Guía de Funcionamiento |publisher=Sinclair Research Ltd and Investronica, S. A. |year=1985 |pages=9}}</ref> one of which was undocumented: * <code>EDITAR</code> (to edit a line number or invoke the full screen string editor) * <code>NUMERO</code> (to renumber the program lines) * <code>BORRAR</code> (to delete program lines) * <code>ANCHO</code> (to set the column width of the [[RS-232]] device, but undocumented as the code was broken) Unlike the <code>LEFT$()</code>, <code>MID$()</code> and <code>RIGHT$()</code> functions used in the ubiquitous Microsoft BASIC dialects for home computers, parts of strings in Sinclair BASIC are accessed by numeric range. For example, {{nowrap|<code>A$(5 TO 10)</code>}} gives a substring starting with the 5th and ending with the 10th character of the variable <code>a$</code>. Thus, it is possible to replace the <code>LEFT$()</code> and <code>RIGHT$()</code> commands by simply omitting the left or right array position respectively; for example {{nowrap|<code>a$( TO 5)</code>}} is equivalent to <code>LEFT$(A$,5)</code>. Further, <code>a$(5)</code> alone is enough to replace <code>MID$(A$,5,1)</code>.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)