AMSTRAD INSTRUCTIONS by CHOIN Nicolas ©1995
If you have questions or suggestions, or if you want to see a doc in this file please write to (join a reproduction):
1 porte de MONS
Information : Ce document est redige en anglais pour une plus large diffusion. Si la demande est suffisante et si le temps me le permet, une version en francais verra jour. Ce document peut etre copie et diffuse librement dans sa forme originale.
Listing of BASIC keywords
& or &H Prefix for hexadecimal constant
&X Prefix for binary constant
: Separates statements typed on the same line
# Prefix for stream director
<string expression> less than 255 characters
numeric data can be either integer or real.
type markers are : % integer
<stream expression> refers to a <numeric expression> which identifies a peripheric.
() are required as part of the command or function.
 enclose optional items.
<> enclose various expressions which are described in the subsequent
“” are parts of the BASIC program structure.
Function : Returns the absolute value of the given expression which primarily means that negative numbers are returned as positive. Syntax : ABS (<numeric expression>)
Example : PRINT ABS(-12.86)
Associated keywords : SGN
Function : Invoke a subroutine after a given time period has elapsed. The first <integer expression> indicates the period of the delay, in unit of 1/50 second, and the second <integer expression> (in range 0...3), indicates which of the four avaible delay timers should be used.
Syntax : AFTER <integer expression>,<integer expression> GOSUB <line>
Example : AFTER 150,2 GOSUB 210
Associated keywords : EVERY, REMAIN
Function : Gets the numeric value of the first character of a string as long as ASCII characters are used.
Syntax : ASC (<string expression>)
Example : PRINT ASC(“X”)
Associated keywords : CHR$
Function : Calculates the arc tangent (forcing the <numeric expression> to a real number ranging from -PI/2 to PI/2) of the value specified. Syntax : ATN(<numeric expression>)
Example : PRINT ATN(1)
Associated keywords : SIN, COS, TAN, DEG, RAD
Function : Generate line numbers automatically. The <line number> sets the first line to be generated, in case you want to add to he end of an existing program. The value of the <increment> between line numbers, and the first line number to be generated. If it is not specified, the default value is 10 In the case of an existing program line is in danger to be overwritten, the BASIC inserts a star * after the line number generated as a warning.
Syntax : AUTO <line number>,<incriment>
Example : AUTO
Function : Produces a string of binary digits that represents the value of the <unsigned integer expression>, filling with leading zeros to the number of digits instructed by the second <integer expression>. Syntax : BIN$(<unsigned integer expression>[,integer expression>])
Example : PRINT BIN$(64,8)
Associated keywords : HEX$, STR$
Function : To change the color of the border on the screen. If two color are specified, the border alternates between the two at the rate determined in the SPEED INK command, if given. The range of border colours is 0...26. Syntax : BORDER <colour>[,<colour>]
Example : BORDER 1
Associated keywords : SPEED INK
Function : Allows an externally developed sub-routine to be invoked from BASIC. Use with caution, not a function for the inexperienced to experiment with.
Syntax : CALL <address expression>[,<list of parameter>]
Example : CALL &BD19
Associated keywords : UNT
Function : Start reading on the drive and display the names of all files found. This does not affect the program currently in memory, and so may be used to verify a program that has just been saved before altering the program memory.
FILENAME BlockNumber Flag OK Flags indicate the type of recording made :
$ a BASIC program file
% a protected BASIC file
· an ASCII text file
Other characters may occur in this column if the file was not produced by BASIC.
If Read error replace Ok, then try to save again or replace the tape.
Associated keywords : LOAD, RUN, SAVE
Function : CHAIN loads a program from tape (or disk) into the memory; replacing the existing program. CHAIN MERGE merges a program from disk (or tape) into the current program memory. It adds the contents of a file to the current program in memory. The <line number expression> indicates the line number from which execution is to begin once the new program is chain merged. In the absence of it, BASIC will default to the lowest line number avaible. If no <file name> is stated, then BASIC will attempt to merge the first valid file encountered. If the first character of the filename is a ! then it is removed from the filename, and suppresses the usual messages generated by the reading process.
CHAIN MERGE retains all current variables although User Functions and open files are discarded. ON ERROR GOTO is turned off, a RESTORE is implemnted and the DEFINT, DEFREAL and DEFSTR settings are reset, and all active FOR, WHILE and GOSUB commands are forgotten. Protected files will not merge. Syntax : CHAIN <Filename>[,<line number expression>]
CHAIN MERGE <filename>[,<linenumber expression>][,DELETE <linenumber range>
Example : CHAIN “TEST”, 450
Associated keywords : LOAD, MERGE
Function : Convert a numeric value to its character equivalent, (using the AMSTRAD CPC character set)
Syntax : CHR$(<integer expression>)
Example : PRINT CHR$(111)
Associated keywords : ASC, LEFT$, RIGHT$, MID$, STR$
Function : Converts the given value to a rounded integer in the range :
· 32768...32767 Syntax : CINT(<numeric expression>) Example : PRINT CIN(276,86)
Associated keywords : CREAL, INT, FIX, ROUND, UNT
Function : Clears all variable and files.
Syntax : CLEAR
Function : Clear the graphics screen.
Syntax : CLG [<masked ink>]
Example : CLG
Associated keywords : CLS, ORIGIN
Function ; Close the input fie. commands such as NEW and CHAIN MERGE will abandon any open files.
Syntax : CLOSEIN
Associated keywords : OPENIN, CLOSEOUT
Function : Close the output file.
Syntax : CLOSEOUT
Associated keywords : OPNOUT, CLOSEIN
Function ; Clear the given screen windows to its Paper Ink.
Syntax : CLS [#stream expression]
Example : CLS
Function : Continue program execution after a Break, STOP or END, as long
as the program has not been altered. Direct commands may be entered
Syntax : CONT
Function : Calculates the cosine of a given value. The function defaults to radian measure unless specifially instructed otherwise by the DEG command. Syntax : COS(<numeric expression>)
Example : PRINT COS(34)
Associated keywords : SIN, TAN, ATN, DEG, RAD
Function : convert a value to a real number. (as opposed to integer).
Syntax : CREAL(<numeric expression>)
Associated keywords : CINT
Function : Declares consttant data for use within a program. One of the most widely used features of BASIC that lumps constant data in DATA statements for retrieval as required. The data type must be consistent with the variable invoking if. A DATA statement may appear anywhere in a program.
Syntax : DATA <list of constan>
Associated keywords : READ, RESTORE
Function : BASIC allows the program to define and use simple value returning functions. DEF FuNction is the definition part of this mechanism and creates program-specific function which works within the program in the same way as a function such a COS operates as a built-in function of BASIC. It may be invoked throughout the program. Variable types must be consistent and the DEF FN command should be written in part of the program outside the execution loop.
Syntax : DEF FN<name>[(<formal parameters>)]=<general expression>
Function : Define default variable types where ‘type’ is integer, real or string. The variable will be set according to the first letter of the variable’s name which may be either upper or lower case.
Syntax : DEFtype <range(s) of letters>
Example : DEFINT I-N
Associated keywords : LOAD, RUN, CHAIN, NEW, CLEAR
Function : Set degrees mode. The command sets to degree mode until instructed otherwise by a CLEAR, RAD or if any new program is loaded.
Syntax : DEG
Associated keywords : RAD
Function : Removes part of the current program as defined in the <line number range> expression.
Syntax : DELETE <line number range>
Example : DELETE 50-100
Associated keywords : NEW
Function : Disable interrupts (other then the Break interrupt) until
re-enable explicitly by EI or implicitly by the RETURN at the end of an
interrupt GOSUB routine.
Used when the program wishes to get on literally without interruption.
Syntax : DI
Associated keywords : EI
Function : Allocate space for arrays and specific maximum subscript values. BASIC must be advised of the space to be reserved for an array, or it will default to 10. Once set either implicitly or explicitly, the size of the array may no be changed, or an error will result.
Syntax: DIM <list of subscripted variables>
Examples : DIM name$(20)
Associated keywords : ERASE
Function : Draws a line on the screen from the current graphics cursor position to an absolute position. The co-ordinate positions remain unchanged between th three different screen modes.(640*400) Syntax : DRAW <X coordinate>,<y coordinate>[,<masked ink>]
Example : DRAW 150,200,1
Associated keywords : DRAWR, PLOT, PLOTR, MOVE, MOVER, TEST, TESTR, XPOS,
Function : Draws a line on the screen from the current graphics cursor to a position relative to it.
Syntax : DRAWR <x offset>,<y offset>[,<masked ink>]
Associated keywords : DRAW, PLOT, PLOTR, MOVE, MOVER, TEST, TESTR ,XPOS,
Function : Edit a program line by calling for a specific line number.
Syntax : EDIT <line number>
Example : EDIT 10
Associated keywords : LIST
Function : Enable interrupts disable by a DI command.
Syntax : DI
Associated keywords: DI
Fuction : End of program. An END is implicit in BASIC as the program passes the last line of instruction. END closes all fils and return to the direct mode. Sound queues will continue until empty.
Syntax : END
Associated keywords : STOP
Function : While a sound is being generated, it is possible to vary its tone A tine envelope defines how the tone is to be varied. The <envelope number> is an <integer expression> whose absolute value must be in the range 1...15, which specifies the tone envelope to set. If the <envelope number> is negative, then the envelope is repeated. Up to five <envelope sections> may be supplied, and each may take one of the forms :
<step count>,<step size>,<pause time>
or:=<tone period>,<pause time>
The first form specifies an incremental change relative to the current tone period setting. The second form specifies an absolute setting for the tone period. Where :
· an <integer expression> in the range 0..239 -
<step size> gives the amount by which to vary the tone period at each step
in the envelope - an <integer expression> yielding a value in the range
· an <integer expression> spcifying the time in 0.01 seconds units. The expression must yield a value in the range 0...255 (where 0 is treated as 256) -
· an <integer expression> yielding a value in the range 0...4095
The SOUND command sets the initial tone period, and may specify on of the fifteen tone envelopes. If no envelope, or an envelope which has not been set up is specified, the the tone remains constant throughout the sound. A tone envelope has no effect on the duration of the sound. If there are steps remaining in the tone envelope when the sound finihses, they are simply abandoned.
A repeating tone envelope will be restarted each time it finishes until the sound terminates.
The expressions in the tone envelope are evaluated when the command is executed and the results strored away for future use. Using the tone envelope does not cause the command to be re-executed. Each time a given tone envelope is set, its previous value is lost. Changing an envelope while a sound using it is active or pending will produce indeterminate effects. (but possibly interesting effects.) Specifying an envelope with no sections cancels any previous setting. Any further use of the envelope will be ignored and the default used instead.
Syntax : ENT <envelope number>[,<envelope sections>]
Example : ENT 1,100,2,20:SOUND 1,100,500,4,0,1
Associated keywords : ENV, SOUND
Function : While a sound is being generated, it is possible to vary its volume using this command. A volume envelope consists of :
<step count>,<step size>,<pause time> and defines how the volume is to be varied, by specifying a number of steps in the range 0..127, the size of the step in the range -128..+127, and the pause time in 0.01 second intervals in the range 1..256. The <envelope number> is an <integer expression> yielding a value in the range 1..15 specifying the volume envelope to set.
Up to five <envelope sections> may be given. Each may take one of the forms:
<step count>,<step size>,<pause time>
or :=<hardware envelopeW,<envelope period>
The first form specifies an envelope section under software control, where the paramaters are :
<step count> gives the number of steps in the section. integer in the range 0..127 <step size> gives the amount by which to vary the amplitude at each step in the envelope. integer in the range -128..+127 <pause time> gives the time to wait between steps. An <integer expression> specifying the time in 1/100th’s of second. The expression must yield a value in the range 0..255 (where 0 is treated as 256) The second form specifies an envelope section to be executed directly by the sound harware, where :
<hardware envelope> is the value to be set into the envelope shape register (register 15,octal).
<envelope period> is the value to be set into the envelope period register (registers 13&14, octal).
Hardware envelope settings do not have an associated pause time, so the next section of the envelope is immediately executed. It is advisable therefor that the next step should have a pause of a suitable length. If there is no next step, then a pause of 2 second is taken. The SOUND command sets the initial volume, and may specify one of the fifteen volume envelopes. If no envelope, or an envelope which has not been set up, is specified, then the volume remains constant throughout the sound.
Setting a <step size> of zero with a non-zero step count causes the current volume setting to be maintained.
The expressions in the amplitude anvelope are evaluated when the command is executed and the results stored away for future use. Using the amplitude envelope does not cause the command to be re-executed. Each time a given amplitude envelope is set, its previous value is lost. Changing an envelope while a sound using it is active or pending will produce indeterminate effects (but possibly ineteresting effects). Specifying an envelope with no sections cancels any previous setting. Any further use of the envelope will be ignored and the default used instead.
Syntax : ENV <envelope number>[,<envelope sections>]
Example : ENV 1,100,2,20:SOUND 1,100,500,4,1
Associated words : ENT, SOUND
Function : Tests to see if the tape inout is at the end of the file.
0 false : not the end
syntax : EOF
example : PRINT EOF
Associated keywords : OPENIN
Function : When an array is no longer required, it may be ERASEd and the memory used be reclaimed ready for other use.
Syntax : ERASE <list of variable name>
Example : ERASE A$,m
Associated keywords : DIM
Function : These variable are used in error handling subroutines to discover the error number and line where the error occured.(-> error message listing)
Syntax : ERR
Associated keywords : ON ERROR, ERROR
Function : Take error action with a given error number. The error may be one already used and recognised by BASIC (-> error message listing), in which wase the action taken is the same as would be taken if such an error had been detected by BASIC. Error numbers beyond those recognised by BASIC may be used by the program to signal its own erros.
Syntax : ERROR <integer expression>
Example : ERROR 12
Associated keywords : ON ERROR, ERR, ERL
Function ; The COC maintains a real time clock. The EVERY command allows a BASIC program to arrange for subroutines to be called at regular intervals. Four delay timers are avaible, specified by the second <integer expression> in the range 0..3 each of which may have a subroutine associated with it.
Syntax : EVERY <integer expression>[,<integer expression>] GOSUB <line>
Example : EVERY 500,2 GOSUB 80
Associated keywords : AFTER, REMAIN
Function : Calculates ‘E’ to the power given in a <numeric expression> (E=2.7182818)
Syntax : EXP(<numeric expression>)
Example : PRINT EXP(6.876)
Associated keywords : LOG
<numeric expression> to the right of the decimal point,and leaves an integer result, rounding towards zero.
Syntax : FIX(<numeric expression>)
Example : PRINT FIX(3.33333)
Associated keywords : CINT, INT, ROUND
Function : Execute a body or program a given number of times, stepping a control variable between a start and an end value. If not specified, STEP defaults to 1.
Syntax : FOR <simple variable>=<start> TO <end> [STEP <size>]
Example : FOR n=1 TO 100 STEP 2
Associated keywords : NEXT, WHILE
Function : Establishes how much memory remains unused by BASIC. The form FRE(“”) forces a ‘garbage collection’ before eturning a value for avaible space.
Syntax : FRE(<numeruc expression>) or FRE(<string expression>)
Example : PRINT FRE(0)
Function : Call a BASIC subroutine by branching to the specified line.
Syntax : GOSUB <line number>
Example : GOSUB 320
Associated keywords : RETURN
Function : Branch to the specified line number.
Syntax : GOTO <line number>
Example : GOTO 60
Function ; Converts the number given into Hexadecimal form. The second <integer expression> can be used to specify the minimum length of the result.
Syntax : HEX$(unsigned integer expression>[,<integer expression>])
Example : PRINT HEX$(65534)
Associated keywords : BIN$, STR$
Syntaxe : This variable gives the adress of the highest byte of memory used by BASIC, and can be used in numeric expressions in the usual way. Before resetting the highest byte of avaible memory using the MEMORY command, it is advisable to issue the command mm=HIMEN. You will thereafter be able to return to the previous memory capacity by issuing the command:
Syntax : HIMEM
Example : PRINT HIMEN
Associated keywords : FRE, MEMORY
Function : A very widely used command that is used to cnditionally determine branch points in a program. The logical part is evaluated, and if true the THEN or GOTO part is executed, if false, the program skips to the ELSE part, or merely passes onto the next line. The statements may be nested to any depth, limited by line lengh. The IF is determinated by the line end. It is not permissable to have further statements that are independent of the IF on the same line.
Syntax : IF <logical expression> THEN <option part> [ELSE <option part>]
IF <logical expression> GOTO <line number> [ELSE <option part>]
IF a>b goto 200
Associated keywords : THEN, ELSE, GOTO, OR, AND, WHILE
Function : Depending on the current Screnn Mode, a number of INKs are avaible. The colour, or colours, used for an INK may be changed by an INK command, according to the table of colour values. Syntax : INK <ink>,<colour>[,<colour>]
Example : INK 0,1
Associated keywords : PEN, PAPER
Function : This function interrogates the keyboard to report which keys are being pressed. The keyboard is scanned at 1/50 sec. Syntax : INKEY(<integer expression>)
Example : IF INKEY(55)=32 GOTO 30
Associated keywords : INPUT, INKEY$
Function : Reads a key from the keyboard to provide operator interaction without hitting [ENTER] after every answer.
Syntax : INKEY$
Example : IF INKEY$=”Y” GOTO 50
Associated keywords : INPUT, INKEY
Function : Returns the input value from the I/O port specified in the adress Syntax : INP(<port number>)
Associated keywords : OUT, WAIT
Function : Reads data from the stated stream. A semicolon after INPUT suppresses the carriage return typed at the end of the line being entered. A semicolon after the <<quoted string> causes a question mark to be displayed. A comma suppresses the question mark. If an entry is made that is of the wrong type (eg a letter O was type instead of a 0 in a <numeric expression>, the the BASIC will prompt with : Redo from start and the original prompt text that you entered. All responses must be terminated with an [ENTER]. The semicolon immediately after the <stream expression> has the effects of suppressing the carriage returned typed at the end of the line being entered, leaving the cursor at the end of the text just entered. Where a tape stream is indicated, no prompt is generated. If one is specified, it will be ignored by the tape software, so the same program may read from either stream. One item will be read from the stream for each variable in the list given.
It must be compatible with the type specified in the INPUT command.
Unquoted string items are terminated as the case of numeric values.
Syntax : INPUT [#<stream expression>,][;][<quoted string>;]<variable>
INPUT [#<stream expression>,][;][<quoted string>,]<variable>
Associated keywords : LINE INPUT, READ, INKEY$
Function : Searches the first <string expression> for the first occurance of the second <string expression>, where the optional number at the start indicates where to start the search - otherwise the searche begins at the first character of the first <string expression>.
INSTR([<integer expression>,]<string expression>,<string expression>)
Associated keywords : MID$, LEFT$, RIGHT$
Function : Rounds the number to the nearest lower integer, removing any fractional part. The same as FIX for positive numbers, but returns one less than FIX for negative numbers not already integers. Syntax : INT(<numeric expression>)
Example : PRINT INT(-1.995)
Associated keywords : CINT, FIX, ROUND
Function : Reads a bit-significant result from the joystick specified in the <integer expression> (either 0 or 1)
0 : UP 1
1 : DOWN 2
2 : LEFT 4
3 : RIGHT 8
4 : FIRE 2 16
5 : FIRE 1 32
Syntax : JOY(<integer expression>)
Associated keywords : INKEY
Function : Fixes a new function key definition. There are thirty two keyboard ‘expansion’ characters in the range 128..159 When one of these characters is read it is expanded into the string associated with it. Although the total number of expansion characters cannot exceed 100. The KEY command associateds a string with a given expansion character. Syntax : KEY <integer expression>,<string expression> Example : KEY 139,”MODE 2:LIST”+CHR$(13)
Associated keywords : KEY DEF
Function : Associates a character value to a key.
Syntax : KEY DEF <key number>,<repeat>[,<normal>[,<shifted>[,<control>]]]
Example : KEY DEF 46,1,63 converts the N key as a ?
Associated keywords : KEY
Function : Extracrs characters to the left of, and including the position specified in the <integer expression> from the given <string expression>. If the <String expression> is shorter than the required lenghth, the whole <string expression> is returned.
Syntax : LEFT$(<string expression>,<integer expression>)
Example : PRINT LEFT$(“AMSTRAD”,3)
Associated keywords : MID$, RIGHT$
Function : Returns a number corresponding to the number of all types of characters, including spaces, in the <string expression>. Syntax : LEN(<string expression>)
Example : A$=”AMSTRAD”:PRINT LEN(A$)
Function : A remnant from early BASICS where varable assignments had to be ‘seen coming’, like PASCAL. No use apart from providing compatibility with the programs supplied in early BASIC training manuals.
Syntax : LET <variable>=<expression>
Example : LET a=25
Function : Reads an entire line form the stream indicated. The first optional semicolon supresses the echo of carriage return / line feed. The default <stream expression> is, as always #0 (screen)
LINE INPUT [<#<stream expression>,][;][quoted string;]<string variable>
LINE INPUT [<#<stream expression>,][;][quoted string,]<string variable>
Example : LINE INPUT “Your name”;N$
Associated keywords : READ, INPUT, INKEY$, INPUT$
Function : List program lines to the given screen. (#0 screen #8 printer)
LISTing may be suspended by [ESC] and restarted by pressing the space bar. A double [EST] will return BASIC to the direct mode. Listing may be performed from the start of a program to a given point, or from a specified line number to the program end, by omitting the first or last number in the <line number range> Syntax : LIST [<line number range>][,#<stream expression>]
Example : LIST -250
Function : Read a BASIC program from a tape into memory, replacing any existing program, or if using the optional address expression, to load a binary file into memory.
Syntax : LOAD <filename>[,<adress expression>]
Example : LOAD “MYPROG”
Function : Moves the text cursor at the stream indicated, to the position specified by the x and y coordinates, which are relative to the origin of the stream (WINDOWD). Stream 0 is the default stream.
Example : LOCATE 10,15:PRINT “OK”
Associated keywords : WINDOWS
Function : Calculates the natural logarithm of <numeric expression> Syntax : LOG(<numeric expression>)
Example : PRINT LOG(9999)
Associated keywords : EXP, LOG10
Function : Calculates the base 10 logarithm of <numeric expression> Syntax : LOG10(<numeric expression>)
Example : PRINT LOG10(9999)
Associated keywords : EXP, LOG
Function : Returns a new string expression the same as the input <string expression> but in which all upper case characters are converted to lowers case.
Syntax : LOWER$(<string expresstion>)
Example : A$=”AMSTraD”:PRINT LOWER$(A$)
Associated keywords : UPPER$
Function : Extracts the largest value from the list of <numeric expression>.
Syntax : MAX(list of<numeric expression)
Example : PRINT MAX (1,2,3,4,5)
Associated keywords : MIN
Function : Reset BASIC memory parameters to change the amount of memory avauble by setting the adress of the highest byte. See the description of the keyword HIMEM. To examine the amount of memory, yse the FRE command.
Syntax : MEMORY <adress expression>
Example MEMORY &20AA
Associated keywords : HIMEM, FRE
Function : Merge a program from tape into the current program memory. It adds the contents of a file to the current program in memory. If no file name is specified, then BASIC will attempt to merge the first valid file encountered on tape. If the first character of the filename is a ! , then it is removed from the filename, and has the effect of suppressing the usual messages generated by the reading process. If you wish to merge a program into memory without overwritting the current program, then the current program lines should be RENUMbered to a range different from those in the incomming program. All variables, User Functions and opened files are discarded. ON ERROR GOTO is turned off, a RESTORE is implemented and the DEFINT, DEFREAL and DEFSTR settings are reset. Protected files will not merge. Syntax : MERGE [<filename>]
Associated keywords : LOAD, CHAIN, CHAIN MERGE
Function : MID$ specifies part of a string (a sub string) which can be used either as the destination of an assignement (MID$ as a command) or as an argument in a string expression (MID$ as a FUNCTION). The first <integer expression> specifies the position of the first character of the sub-string.
The second <integer expression> specifies the length of the sub string to be returned. If omitted, this extends to the end of the original string.
MID$(<string>,<integer expression>[,<integer expression>])
Associated keywords : LEFT$, RIGHT$
Function : Extracts the smallest value from the list of <numeric expression> Syntax : MIN(<list of numeric expression>)
Example PRINT MIN(1,2,3,4)
Associated keywords : MAX
Function : Changes the screen mode (0,1 or 2) and clear the screen to ink 0 which may not be the current PAPER INK. All text and graphics WINDOWS are reset to the whole screen, and the text and graphics cursors homed to their respective origins.
Syntax : MODE winteger expression>
Example : MODE 2
Associated keywords : WINDOWS, ORIGIN
Function : Moves the graphics cursor to a position specified by the
absolute coordinates. YPOS and XPOS are the corresponding functions to
Syntax : MOVE <x coord>,<y coor>
Example : MOVE 20,30
Associated keywords : MOVER, PLOT, PLOTR, DRAW, DRAWR, ORIGIN, TEST, TESTR,
Function : Moves the graphics cursor to a postion relative to the current coordinates. YPOS and XPOS are the corresponding functions to establish the current graphics cursor positon.
Syntax : MOVER <x offste>,<y offset>
Example : MOVER 20,30
Associated keywords : MOVE, PLOT, PLOTR, DRAW, DRAWR, TEST, TESTR, XPOS,
Function : Delete current program and variables. KEY definition are not lost and the display is not cleared.
Syntax : NEW
Function : Delimits the end of a FOR loop. The NEXT command may be anonymous, or may nefer to its matching FOR.
Syntax : NEXT [<list of variable>]
Associated keywords : FOR
Function : GOSUB to the subroutine, or GOTO the statement as directed by the result of the <integer expression>. If the result is 1, then the first line number in the list is chosen, if 2 then the second etc.
Syntax : ON <integer expression> GOSUB <list of line number>
ON <integer expression> GOTO <list of line number>
Associated keywords : GOTO, GOSUB
Function : Calls a sybroutine on a breaking from program execution by pressing [ESC] twice.
Syntax : ON BREAK GOSUB <line number>
Associated keywords : ON BREAK STOP, RETURN
Function : When issued in an ON BREAK interrupt subroutine, ON BREAK STOP disables the trap, but has no other immediate effects.
Syntax : ON BREAK STOP
Associated keywords : ON BREAK GOSUB
Function : Go to a specified line number in the program on detecting an error.
Syntax : ON ERROR GOTO <line number>
Associated keywords : ERR, ERL, RESUME
Function : Enable an interrupt for when there is a free slot in the given sound queue. The <channel> is an integer expression yielding one of the values :
1 : for channel A
2 : for channel B
3 : for channel C
Syntax : ON SQ (<channel>) GOSUB <line number>
Example : ON SQ (1) GOSUB 550
Associated keywords : SOUND, SQ
Function ; Opens an input file from tape which contains informations for use in the current program int the computer’s memory. If the first character in the <file name> is ! the the display processing messages are suppressed.
Syntax : OPENIN <filename>
Example : 50 OPENIN “!DATA”
Associated keywords : CLOSEIN, OPENOUT
Function : Opens an output file onto tape for use with the current program
in the computer’s memory. If the first character in the <fliename> is a !
the the displayed processing messages are suppressed. The program creates
the first block of data, in the file with the given name. Each block
consists of up to 2048 bytes of DATA
Syntax : OPENOUT <file name>
Example : OPENOUT “!DATA”
Warning : a NEW command will abandin any open file buffered, and data will be lost.
Associated keywords : CLOSEOUT, OPENIN
Function ; determines the start point for the graphics cursor. The optional part of the command contains the instructions to set a new graphics windows, which will be operational in all screen modes due the pixel adressing technique employed. The ORIGIN is the point with coordinate 0,0 (grow up and right). If any of the windows edges are specified to a position that is off the screen, they are assumed to represent the furthest ‘visible’ postion in the given direction.
Syntax : ORIGIN <x>,<y>[,<left>,<right>,<top>,<bottom>]
Associated keywords : WINDOW
Function : Sends the value in the <integer expression> (which must lie in the range 0..255) to the prot specified in the <port number> by its address.
Associated keywords : INP, WAIT
Function : Sets the background ink for characters. when characters are written to the text screen, the character cell is filled with the paper ink before the character is written - unless the transparent mode has been selected.
Example : PAPER 5
Associated keywords : INK, WINDOWS, PEN
Function : Examine the contents of a memory location.
Syntax : PEEK(<adress expression>)
Associated keywords : POKE
Function : sets the ink to be used when drawing at the given screen stream,
defaulting to screen #0
Syntax : PEN [#<stream expression>,]<masked ink>
Example : PEN 1,3
Associated keywords : INK, PAPER
Funtion : The value of the ratio between the circumference and the diameter of a circle.
Syntax : PI
Example : PRINT PI
Associated keywords : DEG, RAD
Function : PLOT is the same as MOVE except that the pixel at the destination is written.
Syntax : PLOT <x coord>,<y coord>[,<masked ink>]
Associated keywords : DRAW, DRAWR, PLOTR, MOVE, MOVER, ORIGIN, TEST, TESTR,
Function : PLOTR is the same as DRAWR, except that only the pixel at the destination is written.
Syntax : PLOTR <x coord>,<y coord>[,<masked ink>]
Associated keywords : DRAW, DRAWR, PLOT, MOVE, MOVER, ORIGIN, TEST, TESTR,
Function : Provides direct acces to the machine memory, and loads the <integer expression> in the range 0..255 directly at the adress specified. Not to be used by the unwary.
Example : POKE &00FF,10
Associated keywords : PEEK
Function : Establishes the current position for a given stream. In this instance there is no default <stream expression>. Screen : return the current X coordinare of the text cursor, relative to the current window origin. The top left corner is represent as 1,1 Printer : Returns the carriage position, where 1 is the left margin. All characters with ASCII reference numbers greater than &1F(31) are included. Tape output stream : As for the printer.
Syntax : POS(#<stream exprression>)
Example : PRINT POS(#0)
Associated keywords : VPOS
Function : Print data at <stream expression> using the format specified. Where no format are specified, BASIC prints in ‘free format’, where a comma followinf the <print item> will send the printed item to start at the next print >ONE (default to 13). A semicolon simply separates the expressions. SPC(<integer expression>) prints the given number of spaces, defaulting to zero if the <numeric expression> is less than 1. SPC does not required to be terminated by a comma or a semicolon - a semicolon is assumed at all times.
TAB(<integer expression>) prints spacces to move to the given print position if less than 1, 1 is assumed.
If the required position is equal to or exceeds the current position, spaces are printed to reach the required postion - if less, then the carriage return is sent, followed by spaces to reach the required postion. TAB does not required termination by a comma or a semicolon.
PRINT [#<stream expression>,][<print list>][<USING clause>][<separator>]
stream expression : #0 screen
Example : PRINT “AMS”+”TRAD”
Associated keywirds : USING, TAB, SPC
Function : Set radians mode.
Syntax : RAD
Associated keywords : DEG
Function : BASIC’s random number generator produces a pseudo random sequence in which each number depends on the previous number - starting from a given number, the sequence is always the same. RANDOMIZE sets a new initial value for the random number generator, either to a given value, or to a value entered by the operator. RANDOMIZE TIME will produce a sequence that will be difficult to repeat.
Syntax : RANDOMIZE [<numeric expression>]
Example : RANDOMIZE 20
Associated keywords : RND
Function : READ fetches data from the list of constants supplied in the corresponding DATA statements and assigns it to variables, automatically stepping to the next item int the data statement. RESTORE will return the pointer to the begining of the DATA statement. (see DATA keyword)
Syntax : READ <list of variable>
Associated keywords : DATA, RESTORE
Function : When a sound is placed on a sound queue it may include a ‘hold’ state. If any of the channel specified in this channel are in ‘hold’ state, then they are released. The expression to identify the sound channel is ‘bit signifiant’ :
Thus 4 releases Queue C.
Syntax : RELEASE <sound channels>
Example : RELEASE 4
Associated keywords : SOUND
Function : Use to plade REMarks in programs without affecting it in any way. The : is ignored. REM must be in the end of a line.
Example : 10 SOUND 1,100,100,2 : REM this is a sound
Function : Disables the specified delay timer (in the rang 0..3) Reads the remaining count from the delay timer. Zero is returned if the delay timer was not enabled.
Syntax : REMAIN(<integer expression>)
Associated keywords : AFTER, EVERY
Function : Renumber program lines from the line specified, using the increment specified. The <new line number> gives the first number for the new sequence, defaulting to 10. The <old line number> identifies where RENUM is to commence , and assumes the first program line if omitted. The <increment> sets the increment to use between the line number, again defaulting to 10. RENUM takes care of all GOTO, GOSUB and other line calls. Line numbers are valid in the range 1...65535 Syntax :
RENUM [<new line number>][,[<old line number>][,<increment>]]
Example : RENUM
Function : Restores the postion of the reading pointer back of the beginning of the DATA statements specified in the optional <line number>. Omitting <line number> restores the postion to the beginning of the first DATA statement.
Syntax : RESTORE [<line number>]
Associated keywords : READ, DATA
Function : When an error has been trapped by an ON ERROR GOTO command, and has been processed, RESUME allows normal program execution to continue, the resuming line number being optionally specifiable. If not specified, the line in which the error has occured is returned to. RESUME NEXT returns to the line immediatly following the statements in which the error was detected Syntax : RESUME [<line number>]
or RESUME NEXT
Associated keywords : ON ERROR GOTO
Function : Signals the end of a subroutine called by a GOSUB command. Returns to continue processing at the point ather the GOSUB which invoked it.
Associated keywords : GOSUB, ON x GOSUB, ON SQ GOSUB, AFTER n GOSUB,
EVERY n GOSUB, ON BREAK GOSUB
Function : Extracts the number of characters specified by the <integer expression> from the right of the <string expression>. If it is shorter than the required length, the whole <string expression> is returned.
Syntax : RIGHT$(<string expression>,<integer expression>)
Example : a$=”AMSTRAD”:PRINT RIGHT$(a$,3”
Associated keywords : MID$, LEFT$
Function : Fetches a random number, which may be the next in sequence, a repeat of the last one, or the first in a new sequence. RND(0) returns a copy of the last random number generated.
Syntax : RND[(numeric expression)]
Associated keywords : RANDOMIZE
Function : Rounds <numeric expression> to a number of decimals places or power of ten specified in <integer expression>. If the <integer expression> is less than zero, then value is rounded to give an absolute integer followed by a number of zeros determined by the <integer expression> before the decimal point.
Syntax : ROUND(<numeric expression>[,<integer expression>])
Associated keywords : INT, FIX, CINT, ABS
Function :RUN <name> loads a program from a cassette and start executing it. if RUN “ loads the first valid program of the tape. If the first character of the expression is a ! then the displayed processing messages are suppressed.
RUN starts executing the current program at the specified line.
RUN <string expression>
RUN [<line number>]
Example : RUN
Associated keywords : LOAD
Function : Save the program in memory with name <file name>.
Binary parameters comprise <start adress>,<file length>[,<entry pint>]
,A saves program in ASCII
,P protects file
,B saves an aread of memory as a binary fie.
Syntax : SAVE <filename>[,<file type>][,<binary parameters>]
Associated keywords : LOAD, RUN, MERGE, CHAIN, CHAIN MERGE
Function : Determines the sign of the <numeric expression>. Returns:
· 1 if <0 0 if =0 1 if >0 Syntax : SGN(<numeric expression>) Associated keywords : ABS
Function : Calculates the real value for the Sine of <numeric expression>.
Defaulting to the radian mesure.
Syntax : SIN(<numeric expression>)
Example : PRINT SIN(PI/2)
Associated keywords : COS, TAN, ATN, DEG, RAD
Form of the command : SOUND G,H,I,J,K,L,M
Where : G: Channel status
H: Tone period
K: Volume envelope
M: Noise period
G : Channel status
value reange 1..255
In the CPC it is possible to play up to three different SOUNDs at once. This is achieved by having three SOUND channels (or queues), referred to as A,B,C The input integer range is given in decimal form, but when converted to an 8 bit value (thus yielding a bit signifiant result), the active bits specify the following commands:
2 1 send SOUND to channel B
4 2 send SOUND to channel C
8 3 rendezvous with channel A
16 4 rendezvous with channel B
32 5 rendezvous with channel C
64 6 hold
128 7 MSB flush
MSB : Most Signifiant Bit
LSB : Least Signifiant Bit
integer entry examples :
98 = 64+32+2
=send the following sound to output channel B, rendezvous with channel C
H : Tone period
Value range 0..4095
Enters a period that sets the frequency of the sound to be palyed (pitch the
note). The frequency can be evaluated form the formula :
Any integer value in the permissable range -32768..+32767 default if omitted : 20 For values greater than zero the value entered represents the duration in 1/100ths second. When equal to zero, the duration is governed by the length of the volume envelope specified.
Where the duration is less than zero, the positive value of this number gives the number of times the volume envelope specified should be repeated.
An ineger value in the range 0..15 (0..7 if no volume envelope is specified) default if omitted : 12 (4 where no volume envelope is specified)
K: Volume Envelope
An ineger value in the range 0..15
default : 0 (if omitted)
The value used specifies a pre-defined envelope. To define an envelope use the ENV commad. A permanent definition is volume <envelope number> 0, this cannot be changed by the ENV command and is set to 2 second consantly at the ‘volume level’.
L : Tone envelope
An integer value in the range ..15
default if omitted : 0
The value used specifies a pre-defined envelope.
M : Noise Period
An integer value in the range 0..15
default if omitted : 0
Specifies a noise to add to the SOUND. Only one noise at the same time.
Example : SOUND 1,200,1000,7,0,0,1
Associated keywords : ENV, ENT
Function : Creates a string of spaces of the given length.
Syntax : SPACE$(<integer expression>)
Example : PRINT SPACE$(5);+”I”
Associated keywords : PRINT, SPC, TAB
Function : The INK and BORDER commands allow two colors to be associated with each Ink, in which case the INK alternates between the two colours. The first <integer expression> specifies the time for the first INK specified to be used, an the 2nd set the 2nd ink. Times between colour changes are mesured in 1/50 second. (50 Hz mains version)
Syntax : SPEED INK <integer expression>,<integer expression>
Example : BORDER 12,9:SPEED INK 50,20
Associated keywords : INK, BORDER
Function : Sets the delays of autorepeat keys. The default rate is set to 30,2. Not all keys repeat.
Example : SPEED KEY 20,3
Associated keywords : KEY DEF
Function : The xassette can be written at either 2000 baud (where <integer expression> is 1), or the default of 1000 baud ( <integer expression> is 0). 1000 baud rate is recommended for maximum reliability.
Syntax : SPEED WRITE <integer expression>
Example : SPEED WRITE 1 : SAVE”PROG”
Associated keywords : SAVE
Function : Check the number of free entries in the queue for a given channel where channel A is 1, B is 2 and C is 3. The function determines whether the channel is active or not. The result is bit signifiant :
3,4,5 indicate the redezvous state
6 is set if the head of the queue is held
7 is set if the channel is currently active
Syntax : SQ(<channel>)
Associated keywords : SOUND, ON SQ GOSUB
Function : Returns the square root of <numeric expression> Syntax : SQR(<numeric expression>)
Example : PRINT SQR(9)
Function : Stops execution of a program, but it can be restarted by the CONT command.
Syntax : STOP
Associated keywords : CONT, END
Function : Converts the <numeric expression> to a decimal string representation in the same form as used in the PRINT command. Syntax : STR$(<numeric expression>)
Example : PRINT STR$(&766)
Associated keywords : VAL, BIN$, HEX$
Function : Delivers a <string expression> consisting of the specified character repeated a number of times.
Syntax : STRING$(<integer expression>,<character specifier>)
Associated keywords : SPACE$
Function : Redefines the representation of a given character that has first been specified in the SYMBOL AFTER command. Character are on 8x8 matrix.
Example : SYMBOL AFTER 80:SYMBOL 82,&80,&40,&20,&10,&8,&4,&2,&1
Associated keywords : SYMBOL AFTER
Function : Defines the number of user definable charaters.
Syntax : SYMBOL AFTER <integer expression>
Example : SYMBOL AFTER 32
Associated keywords : SYMBOL
Function : Text send to a given stream may be redirected to be written at the graphics cursor posqition. This allows text and symbol to be mixed with graphics.
Syntax : TAG [#<stream expression>] default is #0 (screen)
Associated keywords : TAGOFF
Function : Cancels the TAG for a given stream.
Syntax : TAGOOFF [#<stream expression>]
Associated keywords : TAG
Function : Calculates the tangent for the angles given in <numeric expression> which must be in the range -200,000...+20,000.
Default in RAD
Syntax : TAN(<numeric expression>)
Associated keywords : COS, SIN, ATN, DEG, RAD
Function : Reports the value of the ink currently at the specified graphics screen location.
Syntax : TEST (<x coord>,<y coord>)
Example : PRINT TEST(300,250)
Associated keywords : TESTR, MOVE, MOVER, PLOT, PLOTR, DRAW, DRAWR
Function : Moves the graphics cursor to the specified location and reports the value of the ink there.
Syntax : TESTR(<x offset>,<y offset>)
Associated keywords : TEST, MOVE, MOVER, PLOT, PLOTR, DRAW, DRAWR
Function : Reports the elaplsed time since switch on, excluding periods when reading or writing the tape. The units of time are 1/300th of second.
Syntax : TIME
Function : BASIC includes the facility to trace the execution of a program, by reporting the number of each line in square brackets .
Syntax : TRON
Function : Converts an unsigned 16 bit integer in the range 0..65535. Returns an integer value in the range -32768..+32767 Syntax : UNT(<adress expression>)
Example : PRINT UNT(65535)
Associated keywords : INT, FIX, CINT, ROUND
Function : Returns a new string expression the same as input but in which all lower case characters are converted to upper case. Syntax : UPPER$(<string expression>)
Example : PRINT UPPER$(“Amstrad”)
Associated keywords : LOWER$
Function : extracts a <numeric expression> from the beginning of the <string expression>. The opposite of STR$.
Syntax : VAL(<string expression>)
Associated keywords : STR$
Function : Returns the vertical position of the text cursor of the
Syntax : VPOS(#<stream expression>)
Associated keywords : POS
Function : Suspends operation until a given I/O port returns a particular value in the range 0..255.
Syntax : WAIT <port number>,<mask>[,<inversion>]
Example : WAIT &FF34,20,25
Associated keywords : INP, OUT
Syntax :The WHILE/WEND loop repeatedly executes a boby of program until a given condition is true.
Syntax : WEND
Associated keywords : WHILE
Function : A WHILE loop repeatedly executes a body of program until a given condition is true. The WHILE command defines the head of the loop, and gives the condition. The WEND command terminates the WHILE loop.
Syntax : WHILE <logical expression>
Example : WHILE a=0
Associated keywords : WEND
Function : Tells to BASIC how wide the printer is in characters, this information allows BASIC to insert carriage returns as required when printing.
Syntax : WIDTH <integer expression>
Example : WIDTH 86
Associated keywords : PRINT, POS
Function : Sets a text window for a given screen stream.
Syntax : WINDOW [#<stream expression>,]<left>,<right>,<top>,<bottom>
Example : WINDOW 10,30,7,18:PAPER 2:PEN0:CLS
Associated keywords : ORIGIN
Function : Exchanges the text windows.
Syntax : WINDOWS SWAP <stream expression>,<stream expression>
Example : WINDOWS SWAP 0,2
Associated keywords : WINDOWS, PEN, PAPER, TAG
Function : Prints the values of a number of expressions to the given stream, separating them by commas and enclosing strings in double quotes. Used mainly for outputting data to cassette files. Syntax : WRITE [#<stream expression>,][<write list>]
Function : Establishes the horizontal position of the graphics cursor.
Associated keywords : YPOS, MOVE, MOVER, ORIGIN
Function : Establish the vertical postion of the graphics cursor.
Associated keywords : XPOS, MOVE, MOVER, ORIGIN
Function : Changes the width of the print zone used in PRINT, from the default value of 13 to a new value in the range 1..255. Reset by NEW, LOAD CHAIN and RUN” commands.
Syntax : ZONE <intager expression>
Example : ZONE 19
Associated keywords : PRINT, WIDTH
ÚÙ DISPLAY SPECIFICATION
MODE Number of inks Vert dots Horiz dots Horiz chars
1 Normal 4 200 320 40
2 High Res 2 200 640 80
0 Multi Colour 16 200 160 20
GREY LEVEL COLOUR
2 Bright blue
6 Bright red
8 Bright magenta
11 Sky blue
14 Pastel blue
17 Pastel magenta
18 Bright green
19 sea green
20 Bright cyan
21 Lime green
22 Pastel green
23 Pastel cyan
24 Bright yellow
25 Pastel yellow
26 Bright white
Ä´ Error codes
A NEXT command has been encountered while not in a FOR loop, or the control variable in the NEXT command does not match in the FOR.
2 Syntax Error
BASIC cannot understand the given line because a construct within is not legal
A RETURN command has been encoutered when not in a subroutine.
A READ command has attempted to read beyond the end of the last DATA.
This is a general purpose error. The value of a function’s argument, or a command parameter is invalid in some way.
The result of an arithmetic operation has overflowed. This may be a floating point overflow, in which case some operation has yielded a value greater than 1.7E-38 Alternatively, this may be result of a failed attempt to change a floating point number to a 16 bit signed integer.
The current program or its variables may be simply too big, or the control structure is too deeply nested (FOR, GOSUB, WHILE)
8 Line does not exist
The line refered cannot be found
One of the subscripts in an aray reference is too big or too small.
One of the arrays in a DIM statement has already been declared.
The last command attempted is not valid in Direct Mode.
A numeric value has been presented where a string value is required, and vice versa, or an invalidly formed number has been found in READ or INPUT.
So many strings have been created that there is not further room avaible, even after ‘garbage collection’.
15 String too long
String exceeds 255 characters in length.
String expressions may generate a number of intermediate string values. When the number of these values exceeds a reasonable limit, BASIC gives up, and this error results.
For one reason or another the current program cannot be restarted using CONT. Not that CONT is intended for restarting after a STOP command, [ESC][ESC], or error, and that any alteration of the program in the meantime makes a restart impossible.
18 Unknown user function
No DEF FN has been executed for the FN just invoked
The end of the program has been encountered while in Error Processing Mode.
(ie in an ON ERROR GOTO routine)
RESUME is only valid while in Error Processing MODE.
21 Direct command found
When loading a program from cassette a line without a line number has been
BASIC has encountered an imcomplete expression.
24 EOF met
An attempt has been made to read past end of file pn the cassette input stream
The cassette file being read is not of suitable type. OPENIN is only prepared to open ASCII text files. LOAD, RUN” etc, are only prepared to deal with the file types produced by SAVE.
26 NEXT missing
Cannot find a NEXT to match a FOR command.
27 File already open
An OPENIN or OPENOUT command has been executed before the previously opened
file has been closed.
BASIC cannot find a taker for an external command.
29 WEND missing
Cannot find a WEND to match a CHILE command.
Encoutered a WEND when not in a WHILE loop, or a WEND that does not match the current WHILE loop.