Changes

Locomotive BASIC

3,388 bytes removed, 07:16, 21 February 2019
/* Functions */
run
</pre>
==== <code><big>SPACE$(i<integer expression>)</big></code> ====: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Creates a string of spaces of the given length, (in the range 0 to 255) specified in the <integer expression>.
: Creates a string containing i spaces (0-255)'''Associated keywords''': SPC, STRING$, TAB
==== <code>SQ (channel)</code> ====: Returns a bit significant integer showing state of the sound queue for specified channel where channel 1, 2, 3 = A, B, C.'''Example''':
<pre>
Bits 0,10 MODE 1 and 2 number of free entries in the queueBits 3,4 and 5 redezvous state at head of the queue20 PRINT "Put 9 spaces between me";Bit 6 head of the queue is held30 PRINT SPACE$(9);40 PRINT "and you!"Bit 7 channel is currently activerun
</pre>
==== <code><big>SQ (<channel>)</big></code> ====
: ''BASIC 1.0 & 1.1''
: '''FUNCTION''': Reports the state of the Sound Queue for the specified <channel> which must be an integer expression, yielding one the values:
: 1: for channel A
: 2: for channel B
: 4: for channel C
: The SQ function returns a bit significant integer, comprising the following bit settings:
: Bit 0,1 and 2: the number of free entries in the queue
: Bit 3,4 and 5: the rendezvous state at the head of this queue
: Bit 6 : the head of the queue is held
: Bit 7 : the channel is currently active
: ... where Bit 0 is the least significant bit, and Bit 7 is the most significant bit.
: It can be seen, that if Bit 6 is set, Bit 7 cannot be set at the same time, and vice versa. Similarly if Bits 3, 4, or 5 are set, Bit 6 and 7 cannot be set.
==== <code>SQR (n)</code> ====: Returns the square root of n.'''Associated keywords''': ON SQ GOSUB, SOUND
: '''Example''':
<pre>
10 SOUND 65,100,100
20 PRINT SQ(1)
run
67
</pre>
==== <code><big>SQR (<numeric expression>)</big></code> ====
: ''BASIC 1.0 & 1.1''
: '''FUNCTION''': Returns the SQuare Root of the specified <numeric expression>.
 
: '''Associated keywords''': none
 
: '''Example''':
<pre>
PRINT SQR(9)
3
</pre>
==== <code>STR$(n)</code> ====
==== <code>YPOS</code> ====
: Returns the current vertical (y) position of the graphics cursor.
 
==== <code>Error codes </code> ====
# '''Unexpected NEXT''' - <code>NEXT</code> encountered without matching <code>FOR</code>.
# '''Syntax Error''' - Typing error or incorrect punctuation.
# '''Unexpected RETURN''' - <code>RETURN</code> encountered when there was no active <code>GOSUB</code>.
# '''DATA exhaused''' - Trying to <code>READ</code> data when data pointer has reached end of data.
# '''Improper argument''' - The argument for a function is not legal (e.g. <code>PRINT SQR(-10)</code>).
# '''Overflow''' - The computer cannot handle integers smaller than -32768 (signed) or larger than 65535 (unsigned) or floating point numbers greater than &plusmn;1.7E38.
# '''Memory full''' - Not enough free RAM available to complete the operation. Program too big or control structures too deeply nested.
# '''Line does not exist''' - Attempt to <code>RUN</code>, <code>GOTO</code> or <code>GOSUB</code> a non-existent line number.
# '''Subscript out of range''' - Value of a subscript in an array is outside of range specified by <code>DIM</code> declaration or wrong number of dimensions supplied.
# '''Array already dimensioned''' - Arrays can only be <code>DIM</code>ensioned once within a program.
# '''Division by zero''' - Trying to divide a number by zero.
# '''Invalid direct command''' - Using a statement as a direct command which is not allowed outside a program, e.g. <code>DEF FN</code>.
# '''Type mismatch''' - Wrong data type encountered, string data instead of numeric value or vice versa.
# '''String space full''' - String memory area is full.
# '''String too long''' - String may not exceed 256 characters.
# '''String expression too complex''' - A string expression needs to be broken down into smaller expressions.
# '''Cannot CONTinue''' - <code>CONT</code> can only be used if program was stopped by [ESC] or a <code>STOP</code> in program - not after END. If the program is modified before issuing <code>CONT</code> you will also get this error.
# '''Unknown user function''' - A <code>DEF FN</code> must be executed before calling an <code>FN</code> function.
# '''RESUME missing''' - End of program has been reached while in error processing mode. Use <code>ON ERROR GOTO</code> before <code>RESUME</code>.
# '''Unexpected RESUME''' - <code>RESUME</code> is only used in error processing mode, <code>ON ERROR GOTO</code> statement must be used first.
# '''Direct Command found''' - A line without a line number has found while loading a file.
# '''Operand missing''' - An incomplete expression has been found.
# '''Line too long''' - The line contains too many statements.
# '''EOF met''' - Trying to input data beyond end of data file.
# '''FILE type error''' - Using a program file instead of a data file to read or write (or vice versa).
# '''NEXT missing''' - The <code>NEXT</code> of a <code>FOR</code> ... <code>NEXT</code> loop is missing.
# '''File already open''' - Trying to open an open file. Use <code>CLOSEIN</code> or <code>CLOSEOUT</code> first.
# '''Unknown command''' - Given when an unknown command follows a <code>|</code>. e.g. <code>|DISC</code> on a CPC464 without AMSDOS installed.
# '''WEND missing''' - The <code>WEND</code> part of the <code>WHILE</code> ... <code>WEND</code> loop is missing.
# '''Unexpected WEND''' - <code>WEND</code> encountered without a corresponding active <code>WHILE</code>.
# '''File not open''' - Attempting to read from or write to a file without <code>OPEN</code>ing it first.
# '''Broken in''' - During handling with files (read, write, change etc.) different problems could appear. BASIC reacts with Error code 32 due to it. You have to mask the DERR code with AND &7F (mask Bit 7) and compare the result with the following table to get explained what happened:
:Decimal (binary) number:
*14 (0000 1110) Stream in an unclear condition
*15 (0000 1111) reached End of File (hard eof
*16 (0001 0000) > unknown command or filename
*17 (0001 0001) > there's already a file existing with the same name
*18 (0001 0010) > there's no file with that name
*19 (0001 0011) > full directory20 (0001 0100) > full disc
*21 (0001 0101) > disc was removed during reading
*22 (0001 0110) > only readable
*26 (0001 1010) > reached End of File (soft end)
:Does AMSDOS has already given out a failure then Bit 7 will be set. That means add 128 decimal to DERR code.
* '''Unknown error''' - Executing <code>ERROR</code> command with any other legal error code number (up to 255).
== Other Basic Dialects available for the CPC ==
205
edits