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!
==Syntax== ===Keywords=== On the 16K/48K ZX Spectrum ('''48 BASIC)''', 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): {| class="wikitable sortable" ! scope="col"|Keyword ! scope="col"|Parameters<ref group="note">Optional parameters are enclosed in [square brackets]</ref> ! scope="col"|Entered using<ref group="note">These assume the computer is in {{font color|white|black| K }} (keyword) mode, which it normally is at the start of a line when entering BASIC. On the Spectrum 16K and 48K, Extended Mode is entered by pressing {{keypress|CAPS SHIFT}} and {{keypress|SYMBOL SHIFT}} simultaneously rather than the {{keypress|EXTENDED MODE}} key that is present on the Spectrum+ and later models.</ref> ! scope="col"|Type ! scope="col"|Summary |- |<code>ABS</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|G}} |Function |Returns the [[absolute value]] of <code>number</code>{{sfn|Vickers|1983|p=59}} |- |<code>ACS</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|W}} |Function |Returns the [[Inverse trigonometric functions|arccosine]] of <code>number</code>{{sfn|Vickers|1983|p=70}} |- |<code>AND</code> | ||{{keypress|SYMBOL SHIFT|Y}} |[[Bitwise operation|Logical operator]] |Returns true if both conditions on either side of the <code>AND</code> keyword are true, else returns false<ref group="note" name="logical"/>{{sfn|Vickers|1983|p=85}} |- |<code>ASN</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|Q}} |Function |Returns the [[inverse trigonometric functions|arcsine]] of <code>number</code>{{sfn|Vickers|1983|p=69β70}} |- |<code>AT</code> |<code>line, column;</code> |{{keypress|SYMBOL SHIFT|I}} |Other |Used in a <code>PRINT</code> statement to print at the line and column specified;{{sfn|Vickers|1983|p=101}} for example, <code>PRINT AT 5,10;"*"</code> puts a star in column 10 of line 5. |- |<code>ATN</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|E}} |Function |Returns the [[inverse trigonometric functions|arctangent]] of <code>number</code>{{sfn|Vickers|1983|p=70}} |- |<code>ATTR</code> |<code>(line, column)</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|L}} |Function |Returns a [[byte]] containing information on the colours of the text cell on the screen, corresponding to the specified <code>line</code> and <code>column</code>; note that, unlike most Sinclair BASIC keywords, the parentheses are required; the first three bits indicate the ink (foreground) colour, the fourth, fifth and sixth bits the paper (background) colour, the seventh bit whether the colours are bright or not, and the eight, whether they are flashing{{sfn|Vickers|1983|p=116}} |- |<code>BEEP</code> |<code>duration, pitch</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|Z}} |Command |Produces sound from the computer's speaker; <code>duration</code> is in seconds, pitch is in [[semitone]]s above (positive value) or below (negative value) [[middle C]]{{sfn|Vickers|1983|p=135}} |- |<code>BIN</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|B}} |Other |Indicates <code>number</code> is in [[Binary number|binary notation]]{{sfn|Vickers|1983|p=93}} |- |<code>BORDER</code> |<code>number</code> |{{keypress|B}} |Command |Sets the border of the screen to the colour specified by the <code>number</code><ref group="note" name="colournumbers"/>{{sfn|Vickers|1983|p=113}} |- |<code>BRIGHT</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|B}} |Command/other |Makes all following colours brighter if <code>number</code> is 1, or its normal shade if 0<ref group="note" name="colours"/>{{sfn|Vickers|1983|p=110β111}} |- |<code>CAT</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|9}} |Command |Displays contents of [[ZX Microdrive]] specified by <code>number</code><ref group="note" name="microdrivecommands"/>{{sfn|Cambridge Communication|1983|p=15}} |- |<code>CHR$</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|U}} |Function |Returns the character corresponding to the decimal <code>number</code> in the computer's [[ZX Spectrum character set|character set]]{{sfn|Vickers|1983|p=91}} |- |<code>CIRCLE</code> |<code>x, y, r</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|H}} |Command |Draws a circle with its centre at coordinates (<code>x</code>,<code>y</code>) and radius <code>r</code>{{sfn|Vickers|1983|p=123}} |- |<code>CLEAR</code> |<code>address</code> |{{keypress|X}} |Command |Clears the screen,{{sfn|Vickers|1983|p=103}} all variables and the <code>GO SUB</code> stack,<ref>{{Cite web|url=https://worldofspectrum.org/ZXBasicManual/zxmanchap24.html|title=World of Spectrum - Documentation - ZX Spectrum manual - Chapter 24|website=worldofspectrum.org}}</ref> and optionally sets the maximum RAM address to be used by BASIC{{sfn|Vickers|1983|p=168}} |- |<code>CLOSE #</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|5}} |Command |Closes the specified stream number for access<ref group="note" name="microdrivecommands"/> |- |<code>CLS</code> | |{{keypress|V}} |Command |Clears all text and graphics from the screen{{sfn|Vickers|1983|p=103}} |- |<code>CODE</code> |<code>string</code> |{{keypress|EXTENDED MODE}} then {{keypress|I}} |Function/other |Returns the number corresponding to the first character in <code>string</code> in the computer's [[ZX Spectrum character set|character set]];{{sfn|Vickers|1983|p=91}} also used to save arbitrary chunks memory to tape, disk, etc. and load them back in β see <code>LOAD</code>, <code>SAVE</code> and <code>VERIFY</code> for details |- |<code>CONTINUE</code> | |{{keypress|C}} |Command |Restarts a program after it has stopped due to an error or the user pressing the {{keypress|CAPS SHIFT|SPACE}} or {{keypress|BREAK}} keys{{sfn|Vickers|1983|p=19}} |- |<code>COPY</code> | |{{keypress|Z}} |Command |Sends the currently displayed screen to the printer{{sfn|Vickers|1983|p=151}} |- |<code>COS</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|W}} |Function |Returns the [[trigonometric functions|cosine]] of <code>number</code>{{sfn|Vickers|1983|p=68}} |- |<code>DATA</code> |<code>comma-separated values</code> |{{keypress|EXTENDED MODE}} then {{keypress|D}} |Command/other |Provides numbers and/or strings to use with the <code>READ</code> command{{sfn|Vickers|1983|p=41}} and allows saving the contents of an array to tape when used with the <code>SAVE</code> command{{sfn|Vickers|1983|p=142}} (as <code>SAVE filename DATA array name()</code>) |- |<code>DEF FN</code> |<code>name(variable) = operation</code> |{{keypress|EXTENDED MODE}} then {{keypress|1}} |Command |Defines a custom function that can be used with the <code>FN</code> command;function definitions must be of the form <code>f(x)=operations</code>, for example <code>f(x)=x*2</code> and the function name may not consist of more than one letter, plus a $-symbol if the function returns a string{{sfn|Vickers|1983|p=60}} |- |<code>DIM</code> |<code>variable(dimensions)</code> |{{keypress|D}} |Command |Declares an array with the specified <code>dimensions</code>, which may be multi-dimensional (for example, <code>DIM a(10,10)</code>; if used with strings, the last dimension indicates the length of each of the strings (thus, <code>DIM A$(2,5)</code> is an array of two strings each of five characters long, and <code>DIM B$(5)</code> is one string of five characters){{sfn|Vickers|1983|p=79β81}} |- |<code>DRAW</code> |<code>x, y [, r]</code> |{{keypress|W}} |Command |Draws a line in the current <code>INK</code> colour to coordinates (<code>x</code>,<code>y</code>) from the coordinates used by the previous <code>PLOT</code> or <code>DRAW</code> command; if the optional <code>r</code> is supplied, it indicates the radius of the circle segment to be drawn, in [[radian]]s{{sfn|Vickers|1983|p=11β123}} |- |<code>ERASE</code> |<code>drive;"filename"</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|7}} |Command |Deletes the specified file from a [[ZX Microdrive]]<ref group="note" name="microdrivecommands"/>{{sfn|Cambridge Communication|1983|p=18}} |- |<code>EXP</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|X}} |Function |Returns [[E (mathematical constant)|''e'']] to the power <code>number</code>{{sfn|Vickers|1983|p=66}} |- |<code>FLASH</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|V}} |Command/other |Makes all following text alternate its foreground (<code>INK</code>) and background (<code>PAPER</code>) colours<ref group="note" name="colours"/> |- |<code>FN</code> |<code>function(value)</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|2}} |Function |Calls the <code>function</code> defined earlier in the program using <code>DEF FN</code>{{sfn|Vickers|1983|p=60}} |- |<code>FORMAT</code> |<code>drive;"name"</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|0}} |Command |Formats the cartridge in the indicated [[ZX Microdrive|Microdrive]] and assigns it the identifier <code>name</code><ref group="note" name="microdrivecommands"/>{{sfn|Cambridge Communication|1983|p=19}} |- |<code>FOR</code> |<code>variable = start TO end</code> |{{keypress|F}} |Command |Starts a <code>FOR</code>-<code>NEXT</code> loop;{{sfn|Vickers|1983|p=31}} the variable name may only be one character long{{sfn|Vickers|1983|p=32}} |- |<code>GO SUB</code> |<code>number</code> |{{keypress|H}} |Command |Makes the program jump to the BASIC line specified by <code>number</code>; when the program encounters the command <code>RETURN</code>, it will jump back to the statement after the <code>GO SUB</code>{{sfn|Vickers|1983|p=37}} |- |<code>GO TO</code> |<code>number</code> |{{keypress|G}} |Command |Makes the program jump to the BASIC line specified by <code>number</code> |- |<code>IF </code> |<code>condition THEN</code> |{{keypress|U}} |Command |Evaluates the <code>condition</code>, and if true, executes the statement that follows the keyword <code>THEN</code> that must come after the condition,{{sfn|Vickers|1983|p=25}} for example {{Code|1=IF A=1 THEN LET B=2|2=basic}}<ref group="note" name="if-else"/> |- |<code>IN</code> |<code>address</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|I}} |Function |Returns a [[byte]] read from the hardware [[memory-mapped I/O|input/output port]] corresponding to the <code>address</code>{{sfn|Vickers|1983|p=159}} |- |<code>INK</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|X}} |Command/other |Sets the foreground colour for text and graphics<ref group="note" name="colournumbers"/><ref group="note" name="colours"/>{{sfn|Vickers|1983|p=110}} |- |<code>INKEY$</code> |<code></code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|Z}} |Function |Returns a string representing the key being pressed on the keyboard at the moment the function is called, or an empty string if none is,{{sfn|Vickers|1983|p=131}} but does not wait for a keypress |- |<code>INPUT</code> |<code>[prompt,] variable</code> |{{keypress|I}} |Command |Halts program execution until the user types in something on the keyboard and presses the <code>Enter</code> key, then stores the entered value in the specified <code>variable</code>; if the optional <code>prompt</code> is supplied, this will be shown on the screen{{sfn|Vickers|1983|p=16}} |- |<code>INT</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|R}} |Function |Returns the [[integer]] value of <code>number</code>, rounding down to the nearest whole number{{sfn|Vickers|1983|p=59}} (thus, <code>INT -1.1</code> returns β2, not β1) |- |<code>INVERSE</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|M}} |Command/other |Reverses the colours on all following text if <code>number</code> is 1, so that it uses the current ink colour for the background and the current paper colour for the text, or sets them back to normal if <code>number</code> is 0<ref group="note" name="colours"/>{{sfn|Vickers|1983|p=112}} |- |<code>LEN</code> |<code>string</code> |{{keypress|EXTENDED MODE}} then {{keypress|K}} |Function |Returns the number of characters (bytes) in <code>string</code>{{sfn|Vickers|1983|p=57}} |- |<code>LET</code> |<code>variable=value</code> |{{keypress|L}} |Command |Assigns <code>value</code> to the named variable{{sfn|Vickers|1983|p=13}} |- |<code>LINE</code> |<code></code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|3}} |Other | * When used in an <code>INPUT</code> statement before a string variable, will not put quotation marks ("") around its prompt,{{sfn|Vickers|1983|p=101}} for example {{Code|INPUT "Name: "; LINE n$|basic}} * When used in a <code>SAVE</code> statement so that when the BASIC program being saved is loaded again, it starts automatically at the line number indicated{{sfn|Vickers|1983|p=144}} |- |<code>LIST</code> |<code>[number]</code> |{{keypress|K}} |Command |Outputs the current BASIC program to the screen; if the optional <code>number</code> is provided, it omits all lines with a lower number{{sfn|Vickers|1983|p=15}} |- |<code>LLIST</code> |<code>[number]</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|V}} |Command |As <code>LIST</code> except the listing is output to the printer{{sfn|Vickers|1983|p=151}} |- |<code>LN</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|Z}} |Function |Returns the [[natural logarithm]] of <code>number</code>{{sfn|Vickers|1983|p=67}} |- |<code>LOAD</code> |<code>"[filename]" <nowiki>[CODE [address[, length]]| DATA variable()]</nowiki></code> |{{keypress|J}} |Command |Loads a program or data into RAM from tape, [[ZX Microdrive]], disk, etc., deleting any existing BASIC program and variables;{{sfn|Vickers|1983|p=16}} if an empty string (<code>""</code>) is provided, this loads the first program found, else it will search the tape for the program named in the string; if the optional <code>CODE</code> is provided, will load the program into memory at the address it had when it was saved, or at the specified <code>address</code> (<code>length</code> is intended as a safety, to try and load the right program in case there are multiple on the tape with the right name but of different lengths);{{sfn|Vickers|1983|p=142β143}} if the optional <code>DATA variable()</code> is provided, will load the data from the tape into the array named <code>variable()</code>{{sfn|Vickers|1983|p=142}} |- |<code>LPRINT</code> |<code>text</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|C}} |Command |As <code>PRINT</code> except output is sent to the printer{{sfn|Vickers|1983|p=151}} |- |<code>MERGE</code> |<code>"[filename]"</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|T}} |Command |As <code>LOAD</code>, except it does not delete the current program and variables; if a line number exists in both, that of the newly loaded program overwrites the existing one. Using <code>MERGE</code> prevents a program saved using <code>LINE</code> from auto-running once loaded{{sfn|Vickers|1983|p=147}} |- |<code>MOVE</code> |<code>stream1 TO stream2</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|6}} |Command |Moves data from one stream (keyboard, screen, file, printer, network, etc.) to another<ref group="note" name="microdrivecommands"/>{{sfn|Cambridge Communication|1983|p=39}} |- |<code>NEW</code> | |{{keypress|A}} |Command |Erases the current BASIC program and all variables{{sfn|Vickers|1983|p=16}} |- |<code>NEXT</code> |<code>variable</code> |{{keypress|N}} |Command |Closes a <code>FOR</code>-<code>NEXT</code> loop; the variable must match that of the corresponding <code>FOR</code> command{{sfn|Vickers|1983|p=31β32}} β "empty" <code>NEXT</code>s to refer to the immediately preceding <code>FOR</code> in the program are not allowed |- |<code>NOT</code> |<code>condition</code> ||{{keypress|SYMBOL SHIFT|S}} |[[Bitwise operation|Logical operator]] |Returns true if the <code>condition</code> is false, else returns false<ref group="note" name="logical"/>{{sfn|Vickers|1983|p=85}} |- |<code>OPEN #</code> |<code>stream</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|4}} |Command |Opens a stream for reading from and/or writing to<ref group="note" name="microdrivecommands"/>{{sfn|Cambridge Communication|1983|p=22}} |- |<code>OR</code> | ||{{keypress|SYMBOL SHIFT|Y}} |[[Bitwise operation|Logical operator]] |Returns true if either of the conditions on either side of the <code>OR</code> keyword are true, else returns false<ref group="note" name="logical"/>{{sfn|Vickers|1983|p=85}} |- |<code>OUT</code> |<code>address, value</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|O}} |Command |Sends the <code>value</code> (a [[byte]]) to the hardware [[memory-mapped I/O|input/output port]] corresponding to the <code>address</code>.{{sfn|Vickers|1983|p=159}} |- |<code>OVER</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|N}} |Command/other |Will make following text overprint with an XOR operation what is already on the screen if <code>number</code> is 1, instead of erasing it, or erase it if <code>number</code> is 0<ref group="note" name="colours"/>{{sfn|Vickers|1983|p=112}} |- |<code>PAPER</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|C}} |Command/other |Sets the background colour for text and graphics<ref group="note" name="colournumbers"/><ref group="note" name="colours"/>{{sfn|Vickers|1983|p=110}} |- |<code>PAUSE</code> |<code>delay</code> |{{keypress|M}} |Command |Halts program execution for the specified delay, in <math>\tfrac {1}{50}</math> of a second in Europe or <math>\tfrac {1}{60}</math> in North America{{sfn|Vickers|1983|p=129}} (thus, <code>PAUSE 50</code> halts for one second in Europe) |- |<code>PEEK</code> |<code>address</code> |{{keypress|EXTENDED MODE}} then {{keypress|O}} |Function |Returns a byte representing the contents of the memory location pointed to by <code>address</code>{{sfn|Vickers|1983|p=130}} |- |<code>PI</code> |<code></code> |{{keypress|EXTENDED MODE}} then {{keypress|M}} |Function |Returns the value of [[pi]]{{sfn|Vickers|1983|p=67}} |- |<code>PLOT</code> |<code>x, y</code> |{{keypress|Q}} |Command |Draws a pixel in the current <code>INK</code> colour on the screen at the coordinates (<code>x</code>,<code>y</code>){{sfn|Vickers|1983|p=121}} |- |<code>POINT</code> |<code>(x,y)</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|8}} |Function |Returns 1 if the pixel pointed at graphical coordinates (<code>x</code>,<code>y</code>) is currently in the ink (foreground) colour, else returns 0{{sfn|Vickers|1983|p=123}} |- |<code>POKE</code> |<code>address, value</code> |{{keypress|O}} |Command |Sets the contents of <code>address</code> in RAM to <code>value</code>{{sfn|Vickers|1983|p=163}} |- |<code>PRINT</code> |<code>[AT x,y;] text</code> |{{keypress|P}} |Command |Prints <code>text</code> (which must be one or more strings or numbers separated with semicolons) to the screen.{{sfn|Vickers|1983|p=13}} If used with #0 or #1, it prints in the bottom two (input) lines of the screen; if used with <code>AT</code>, it prints at the specified text coordinates; otherwise, it prints either immediately following the output of any previous <code>PRINT</code> statement (if the previous statement ended in a semicolon), or in the first column of the line below the previous <code>PRINT</code> output,{{sfn|Vickers|1983|p=101}} defaulting to 0,0. |- |<code>RANDOMIZE</code> |<code>[number]</code> |{{keypress|T}} |Command |Initializes the [[random number generator]]; if used without a <code>number</code> (or with 0), it does this based on the computer's internal clock, else it uses the <code>number</code> supplied, which must be in the range [1,65535]{{sfn|Vickers|1983|p=74}} |- |<code>READ</code> |<code>variable</code> |{{keypress|EXTENDED MODE}} then {{keypress|A}} |Command |Takes a value from a <code>DATA</code> statement and stores it in the named <code>variable</code>: the first time <code>READ</code> is used, it gets the first value after the first <code>DATA</code>, the second time it gets the next one, and so on{{sfn|Vickers|1983|p=41}} |- |<code>REM</code> |text |{{keypress|E}} |Command |Begins a comment in the source code, meaning that everything after the <code>REM</code> statement is ignored, until the end of the line{{sfn|Vickers|1983|p=16}} β note this includes everything after a colon, which normally begins a new segment: {{Code|10 REM Nothing to see here: PRINT "Unprintable"|basic}} will not produce any output, for example. |- |<code>RESTORE</code> |<code>[number]</code> |{{keypress|EXTENDED MODE}} then {{keypress|S}} |Command |Resets where <code>READ</code> commands look for values in <code>DATA</code> statements: if used without a number, the next <code>READ</code> will use the first <code>DATA</code> in the program, with a number it will use the first <code>DATA</code> on or after the line whose number is indicated{{sfn|Vickers|1983|p=42}} |- |<code>RETURN</code> | |{{keypress|Y}} |Command |Returns execution to the first statement following the last <code>GO SUB</code> command that was executed{{sfn|Vickers|1983|p=37}} |- |<code>RND</code> |<code></code> |{{keypress|EXTENDED MODE}} then {{keypress|T}} |Function |Returns a pseudo-random number with eight [[significant figure]]s in the range [0,1){{sfn|Vickers|1983|p=73}} |- |<code>RUN</code> |<code>[number]</code> |{{keypress|R}} |Command |Starts the current BASIC program, from its first line if no <code>number</code> is specified, else from the line with that number (or the first one after, if it does not exist){{sfn|Vickers|1983|p=14}} |- |<code>SAVE</code> |<code>"filename" [DATA variable() {{pipe}} LINE number]</code> |{{keypress|S}} |Command |Saves the current BASIC program to tape or other storage device, with the <code>filename</code> specified; if the optional <code>LINE</code> followed by a line number is used, then the program will start automatically at the indicated line number when it is <code>LOAD</code>ed back in; with the optional <code>DATA</code>, the command saves the contents of the array named by the variable instead of the current BASIC program{{sfn|Vickers|1983|p=142}} |- |<code>SCREEN$</code> |<code>[(line, column)]</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT}}+{{keypress|}} |Function/other |As a function, identifies the character at the specified line and column on the screen.{{sfn|Vickers|1983|p=101}} Used after the filename in a <code>LOAD</code> or <code>SAVE</code> command, indicates that the contents of the [[display memory]] should be loaded or saved; this essentially makes it a shortcut for <code>CODE 16384,6912</code><ref group=note>The Spectrumβs display memory starts at address 16384 and is 6912 bytes long.</ref> but does not work with <code>VERIFY</code> because the contents of the display memory will be different by the time that command reads back the saved data;{{sfn|Vickers|1983|p=143}} |- |<code>SGN</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|F}} |Function |Returns 1 if <code>number</code> is positive, 0 if it is 0, and β1 if it is negative{{sfn|Vickers|1983|p=59}} |- |<code>SIN</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|Q}} |Function |Returns the [[Trigonometric functions|sine]] of <code>number</code>{{sfn|Vickers|1983|p=68}} |- |<code>STEP</code> |<code>number</code> |{{keypress|SYMBOL SHIFT|D}} |Other |Indicates the interval used by a <code>FOR</code> statement,{{sfn|Vickers|1983|p=32}} for example {{Code|1=FOR n=2 TO 6 STEP 2|2=basic}} will skip <code>n=3</code> and <code>n=5</code> in the loop |- |<code>STOP</code> | |{{keypress|SYMBOL SHIFT|A}} |Command |Ends execution of the current program, exiting to the BASIC editor; can also be given when the computer is waiting for input using the <code>INPUT</code> command;{{sfn|Vickers|1983|p=14}} once the program is stopped, it can be resumed with <code>CONTINUE</code> |- |<code>SQR</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|H}} |Function |Returns the [[square root]] of <code>number</code>{{sfn|Vickers|1983|p=60}} |- |<code>STR$</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|Y}} |Function |Converts a number to string. |- |<code>TAB</code> |<code>column</code> |{{keypress|EXTENDED MODE}} then {{keypress|P}} |Other |In a <code>PRINT</code> statement, makes sure that the text to be output begins in the column specified, wrapping to the next line as necessary, but never more than one line{{sfn|Vickers|1983|p=103}} |- |<code>TAN</code> |<code>number</code> |{{keypress|EXTENDED MODE}} then {{keypress|E}} |Function |Returns the [[Trigonometric functions|tangent]] of <code>number</code>{{sfn|Vickers|1983|p=69}} |- |<code>THEN</code> |<code>statement</code> |{{keypress|SYMBOL SHIFT|G}} |Other |Follows the condition in an <code>IF</code> statement to indicate what should happen when the condition evaluates to true<ref group="note" name="if-else"/>{{sfn|Vickers|1983|p=25}} |- |<code>TO</code> |<code></code> |{{keypress|SYMBOL SHIFT|F}} |Other |Indicates a range from the number to the left of <code>TO</code> to the number of the right of it, inclusive;{{sfn|Vickers|1983|p=32, 51}} when used with <code>FOR</code> both numbers must be supplied, while if used to slice strings, either may be left off to indicate the start or end of the string |- |<code>USR</code> |<code>string or address</code> |{{keypress|EXTENDED MODE}} then {{keypress|L}} |Function |When called with a single-character string, this returns the memory address at which the [[glyph]] for the user-defined graphic character corresponding to that character is defined.{{sfn|Vickers|1983|p=93}} If called with an address, it starts [[machine code]] execution at that address (thus making it one of the few Sinclair BASIC functions to have a [[Side effect (computer science)|Side effect]]) and returns the contents of the [[Zilog Z80|Z80]]βs BC [[Processor register|register]] pair.{{sfn|Vickers|1983|p=180}} |- |<code>VAL</code> |<code>string</code> |{{keypress|EXTENDED MODE}} then {{keypress|J}} |Function |Evaluates the <code>string</code> as a number and returns the result;{{sfn|Vickers|1983|p=}} this can perform calculations: <code>VAL "1+2"</code> returns 3, for example, and also evaluates variables and even other <code>VAL</code> statements: {{Code|1=LET A=1: VAL "A+VAL ""2"""|2=basic}}<ref group="note">A string inside a string must have its quotes doubled in Sinclair BASIC.</ref> also returns 3 |- |<code>VAL$</code> |<code>string</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|J}} |Function |Similar to <code>VAL</code> but evaluates the string as a string{{sfn|Vickers|1983|p=59}} |- |<code>VERIFY</code> |<code>"[filename]"</code> |{{keypress|EXTENDED MODE}} then {{keypress|SYMBOL SHIFT|R}} |Command |Reads a program or data from tape or other storage, much like <code>LOAD</code>, but instead of loading it into memory, compares it with the program or data that is already in memory. This is intended to be used immediately after a <code>SAVE</code> command, to make sure the program or data has been saved without corruption.{{sfn|Vickers|1983|p=141}} |} {{multiple image | width = | direction = vertical | image1 = Sinclair ZX Spectrum.jpg | caption1 = ZX Spectrum | image2 = ZX Spectrum+.jpg | caption2 = ZX Spectrum+ }}
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)