Changes

Jump to: navigation, search

Locomotive BASIC

2,569 bytes added, 19:55, 3 January 2019
/* Functions */
==== <code>ABS (n)</code> ====
: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Returns the ABSolute value of the given numeric expression (n). This means that negative numbers are returned as positive.: '''Associated keywords''': SGN
: '''Example''':
<pre>
==== <code>ASC (s)</code> ====
: ''BASIC 1.0 & 1.1''
: '''FUNCTION''': Returns the numeric value of the first character in the <string expression> (s).
: '''Associated keywords''': CHR$
: FUNCTION: Returns the numeric value of the first character in the <string expression> (s).: Associated keywords: CHR$ : '''Example''':
<pre>
PRINT ASC("x")
==== <code>ATN (n)</code> ====
: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Calculates the Arc-TaNgent of the <numeric expression> (n)to a real number ranging from -PI/2 to +PI/2 of the value specified.
: Note that DEG and RAD can be used to force the result of the below calculation to degrees or radians respectively.
: '''Associated keywords''': COS, DEG, RAD, SIN, TAN
: '''Example''':
<pre>
PRINT ATN(1)
==== <code>BIN$ (i1,[i2])</code> ====
: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Produces a string of BINary digits respresenting the value of the <unsigned integer expression>, using the number of binary digits instruced by the second <integer expression> (in the range of 0 to 16). If the number of digits instructed is too great, the resulting expression will be filled with leading zeros; if the number of digits instructed is too small, the resulting expression will NOT be shortened to the instructed number of digits, but will produced in as many digits as are required.
: The <unsigned integer expression> to be converted into binary form must yield a value in the range -32768 to 65535.
: '''Associated keywords''': DEC$, HEX$, STR$: '''Example''':
<pre>
==== <code>CHR$ (n)</code> ====
: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Converts an <integer expression> in the range 0 to 255, to its CHaRacter $tring equivalent, using the AMSTRAD character set shown in the ASCII table or e.g. in the manual part 3.
: Note that 0 to 31 are control characters; hence the below example prints CHR$(x) in the range 32 to 255
: '''Associated keywords''': ASC, LEFT$, RIGHT$, MID$, STR$
: '''Example'''
<pre>
10 FOR X=32 to 255
==== <code>CINT (n)</code> ====
: ''BASIC 1.0 & 1.1''
: '''FUNCTION''': Returns the value of the <numeric expression> (n), Converting it to a rounded INTeger in the range -32768 to 32767.
: FUNCTION'''Associated keywords''': Returns the value of the <numeric expression> (n)CREAL, Converting it to a rounded INTeger in the range -32768 to 32767.FIX, INT, ROUND, UNT
: Associated keywords: CREAL, FIX, INT, ROUND, UNT : '''Example''':
<pre>
==== <code>COPYCHR$ (#stream)</code> ====
: : ''BASIC 1.1'': '''FUNCTION''': COPies a CHaRacter from the current position in the stream (which MUST be specified). The below program copies a character from location 1,1 (top left), and reproduces it at location 1,20.
: If the character read is not recognized, a null string is returned.
: '''Associated keywords''': LOCATE
: '''Example''':
<pre>
10 CLS
==== <code>COS (n)</code> ====
: ''BASIC 1.0 & 1.1'': '''FUNCTION''': Calculates the COSinus of the <numeric expression> (n).
: Note that DEG and RAD can be used to force the result of the below calculation to degrees or radians respectively.
: '''Associated keywords''': ATN, DEG, RAD, SIN
: '''Example''':
<pre>
DEG
==== <code>CREAL (n)</code> ====
: ''BASIC 1.0 & 1.1''
: '''FUNCTION''': Returns the value of the <numeric expression> (n), Converting it to REAL.
: FUNCTION'''Associated keywords''': Returns the value of the <numeric expression> (n), Converting it to REAL.CINT
: Associated keywords: CINT : '''Example''':
<pre>
10 a=PI
==== <code>DEC$(n, format)</code> ====
: ''BASIC 1.1'': '''FUNCTIION''': Returns a DECimal string representation of the <numeric expression> (n), using the specified <format template> to control the print format of the resulting string.
: The format template may contain ONLY the characters:
: The use of these 'format field specifiers' is described under the keyword PRINT USING.
: '''Associated keyword''': BIN$, HEX$, PRINT USING, STR$
: '''Example''':
<pre>
PRINT DEC$(10^7,"££########,.##")
==== <code>DERR</code> ====
: ''BASIC 1.1''
: '''FUNCTION''': Reports the last error code returned by the disc filing system. The value of DERR may be used to ascertain the particular Disc ERRor that occurred. See the listing of error messages below.
: FUNCTION'''Associated keywords''': Reports the last error code returned by the disc filing system. The value of DERR may be used to ascertain the particular Disc ERRor that occurred. See the listing of error messages below.ERL, ERR, ERROR, ON ERROR GOTO, RESUME
: Associated keywords: ERL, ERR, ERROR, ON ERROR GOTO, RESUME : '''Example''':
<pre>
LOAD "xyz.abc"
</pre>
: '''Table of error Disc ERRor codes''':
<pre>
===============================================================================
| '''VALUE ''' | NAME '''DERR value''' | '''DESCRIPTION ''' |
===============================================================================
| 1 0 |Unexpected NEXT 0 or 22 |A NEXT command [ESC] has been encountered while pressed || 14 | 142 (128+14) | The stream is not in a suitable state. || 15 | 143 (128+15) | Hard end of file has been reached. || 16 | 144 (128+16) |FOR loopBad command, or the control variable in the NEXT usually an incorrect filename. || 17 | 145 (128+17) |command File already exists. || 18 | 146 (128+18) | File does not match that in the FORexists. || 19 2 | 147 (128+19) |Syntax Error |BASIC cannot understand the given line because Direcotry is full. || 20 | 148 (128+20) |a construct within it Disc is not legalfull. || 21 | 149 (128+21) | Disc changed while file were open. || 22 | 150 (128+22) | File is Read/Only. || 26 | 154 (128+26) | Soft end of file has been detected. |
| | | |
===============================================================================
</pre>
==== <code>EOF</code> ====
: ''BASIC 1.1''
: '''FUNCTION''': Checks to see if end of specified file has been reached during input. Returns 0 (false) until the end of file, then -1 (true).
: Checks to see if end of specified file has been reached during input. Returns 0 (false) until the end of file'''Associated keywords''': OPENIN, then -1 (true)CLOSEIN
 : This '''example ''' reads a file from disc and print it out on screen. Like the "TYPE" command in CP/M or "|TYPE,file" of the UTOPIA-ROM.
<pre>
10 OPENIN "text.txt"
==== <code>ERR</code> ====
: ''BASIC 1.0 & 1.1''
: '''FUNCTION''': Reports the number of the last ERRor encountered. See the table below of error messages. In the example below you will see that ERRor number 8 is a <pre>'Line does not exist'</pre> error
: Returns '''Example''':<pre>GOTO 500Line does not existReadyPRINT ERR 8</pre> : '''Table of ERRor codes''':<pre>=================================================================================| VALUE | NAME | DESCRIPTION |=================================================================================| 1 |Unexpected NEXT |A NEXT command has been encountered while not in a || | |FOR loop, or the error code number control variable in the NEXT || | |command does not match that in the FOR. || 2 |Syntax Error |BASIC cannot understand the given line because || | |a construct within it is not legal. || 3 |Unexpected RETURN |A RETURN command has been encountered when not in a || | |subroutine. || 4 |DATA exhausted |A READ command has attempted to read beyond the end || | |of the last error encounteredDATA. || | | || | | || | | |</pre>
==== <code>EXP (i)</code> ====
205
edits