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!
===Program editing=== Like most home-computer BASICs, Sinclair BASIC is anchored around its [[line editor]]. When the machine is booted, it runs BASIC and displays an [[inverse video]] "K" at the bottom of the screen to indicate the entry point. When a line is entered and the {{keypress|NEW LINE}} key is pressed, it either runs immediately if it does not have a [[line number]] prefix, or clears the screen and performs the equivalent of a {{code|LIST}} command, placing a ">" cursor after the line number in the most recently entered line. In contrast to most machines of the era, the editor does not allow freeform editing at any point on the screen. Instead, when the user presses {{key press|EDIT}}, the current line of code is copied back to the bottom of the screen. The user can move horizontally through this line using the [[cursor key]]s and commits their changes by pressing {{key press|NEW LINE}} again. In contrast, on machines like the [[Commodore 64]] or [[Atari 8-bit computers]], the up and down keys can be used to move among the lines in the program and edit them in-place. The most notable feature of the editor is that keywords are entered using single keystrokes. For instance, on the ZX81, the {{key press|P}} key on the keyboard would cause the entire keyword {{code|PRINT}} to be entered into the currently editing line. Once a keyword has been entered, the cursor changes to an "L" to indicate what follows will be interpreted as normal text. For instance, pressing {{key press|P}} again at this point would enter a single letter "P". Keys generally had two separate keywords assigned to them{{snd}} one above it and one below. Pressing the key in "K" mode would enter the keyword above the key, like {{code|PRINT}} for {{key|P}}. If the system was in "L" mode, one could return to "K" by pressing the [[shift key]]{{snd}} the systems did not initially support [[lowercase]] text, so the shift was not otherwise needed. The keywords below the keys required a second keystroke, {{key press|SHIFT|NEW LINE}}, which put the editor into "function mode", changing the cursor to an "F". Entering common code often resulted in a significant number of keystrokes. The system has the advantage of representing all multi-character keywords as a single character in memory, which was a significant savings in the early machines that shipped with only 1 KB of RAM. This single-character representation included multi-character items like {{code|<>}}. This has the added advantages of simplifying the runtime, as it can immediately determine whether a character in the [[source code]] is a keyword or text, and also means that keywords are never entered directly, meaning that one can, for instance, have a variable named "PRINT", as the system can determine that it is not the same as the keyword. As the systems evolved and added new keywords, the entry system became increasingly difficult to use. 48 BASIC in the Spectrum required every key to host up to four keywords. Entering keywords was a time-consuming process of looking over the relatively small type on the keyboard for the appropriate key, and then correctly entering the multiple keystrokes needed to enter it properly. For instance, entering {{code|BEEP}} required one to type {{keypress|CAPS SHIFT|SYMBOL SHIFT}} to access extended mode (later models include a separate {{keypress|EXTENDED MODE}} key), keeping {{keypress|SYMBOL SHIFT}} held down, and then and pressing {{keypress|Z}}. To improve the complex entry on the Spectrum, the keywords were colour-coded to indicate the required mode:{{sfn|Vickers|1983|p=7β8}} * {{font color|white|gray|White}}: key only * {{font color|red|gray|Red}} on the key itself: {{keypress|SYMBOL SHIFT}} plus the key * {{font color|green|black|Green}} above the key: {{keypress|EXTENDED MODE}} followed by the key * {{font color|red|black|Red}} below the key: {{keypress|EXTENDED MODE}} followed by {{keypress|SYMBOL SHIFT}} plus the key This concept had run its course, and later machines running '''128 BASIC''' (ZX Spectrum 128, +2, +3, +2A, and +2B) featured a more traditional editor where the user typed-in the keyword as individual characters, similar to other home computers of the era. This required a new tokenizer to convert the line into a similar internal format. The resulting in-memory storage of the program was otherwise similar to [[Microsoft BASIC]], in that only the keywords are presented as tokens, while non-keywords{{snd}} like string and numeric constants and variable names{{snd}} are left in their original typed-in format. However, that typed-in format was not [[ASCII]], but an internal character code that contains both printable characters and the keyword tokens. Although portions of the table, the capital letters A to Z, for instance, are in the same order as in ASCII, their characters correspond to different numeric values, i.e. their [[code point]]s' offset from zero is different from ASCII's offset of 65. Other characters, like punctuation, may have been moved about even more. The [[ZX Spectrum character set]] is the most prominent example of such a character code. Related computers running Sinclair BASIC used similar variants, e.g. the [[ZX80 character set|ZX80]] or [[ZX81 character set]]s. All of these different but related character sets included Sinclair BASIC tokens.
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)