FUNCTION: Returns the ABSolute value of the given numeric expression (n). This means that negative numbers are returned as positive.
Associated keywords: SGN
Example:
PRINT ABS(-67.98)
67.98
Waits for <time delay>/50 seconds and then jumps NON-RECURRING to the subroutine at <line number> (see also "EVERY i[,t] GOSUB line").
defines an alias as a shortcut of any command. The command is the coplete rest of the line. Aliases are stored in ~/.basicsh_aliases and permanent
To unalias, just define an empty command.
ALIAS PRINT shows all aliases.
FUNCTION: Returns the numeric value of the first character in the <string expression> (s).
Associated keywords: CHR$
Example:
PRINT ASC("x")
120
Hint:in other languages this is the ord() function
FUNCTION: Calculates the Real value for the Arc-TaNgent of <numeric expression>, (n) to a real number ranging from -PI/2 to +PI/2 of the value specified.
Creates automatically numbers for programming code
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 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:
PRINT BIN$(66,8)
01000000
Sets the Border color to i1. If i2 is given, the border is flashing. Instead color index number (0..28) you can use RGB colors (#123456)
exits the BASIC interpreter. With i=0 no message appears
Allows a machine code routine to be called by BASIC.
CALL 0:REM resets the computer completely
CALL &BB18:REM wait until any key is pressed
CALL &BD19:REM same as FRAME
Displays the names of the files on the tape or disc.
Change Directory (not in originally Locomotive BASIC)
FUNCTION: Returns the value of the <numeric expression> (n), Converting it to a rounded INTeger in the range -32768 to 32767 (or more in this interpreter).
Associated keywords: CREAL, FIX, INT, ROUND, UNT
Example:
10 n=-2.6
20 PRINT CINT(n)
run
-3
Draws a circle on the screen
Enables the specified program to be loaded and RUN automatically. If the optional parameter <line number expression> is specified, the program execution will commence from that line.
Loads the specified program from tape or disc, merges it into the program in memory, and starts execution of the merged program. The parameter DELETE <line number range> is used to delete part of the original program before running it, if required.
CLEAR Clears all variables from memory, leaving the program in memory unchanged. All open files are abandoned.
The command clear inside a subroutine (GOSUB... RETURN) will also clear the "stack pointer" address of the gosub heap. That means that a RETURN won't work and a GOTO has to be used instead.
CLEAR INPUT clears the key buffer.
Clears the graphics screen to colour specified by <masked ink>. If parameter <masked ink> is not specified then the graphics screen is cleared to the colour specified by the GRAPHICS PAPER statement.
Closes any input file
Closes any output file
Clears the window specified by <stream expression>. If <stream expression> is omitted it defaults to #0 (usually the whole screen). The text cursor of the stream is moved to the upper left corner.
CONTinues program execution interrupted either by [ESC] [ESC] or as a result of STOP within a program. A program cannot be continued after being modified.
FUNCTION: COPies a CHaRacter from the current position in the stream (which MUST be specified). If the character read is not recognized, a null string is returned. This works only in graphic mode!
FUNCTION: Calculates the Real value for the Cosinus of <numeric expression>, defaulting to the Radian (RAD) measure mode unless otherwise declared by a DEG command.
FUNCTION: Returns the value of the <numeric expression> (n), Converting it to REAL.
enables (1) or disables (0) the cursor.
Defines a data section to be used by READ calls.
Data values can be of any type (integer, real or string) as long as the corresponding READ calls use a variable of the right type.
Example:
10 DATA "Hello, world!", 42
20 READ message$:PRINT message$
30 READ answer:PRINT "The answer is:";answer
See also: READ, RESTORE
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.
Example:
PRINT DEC$(10^7,"££########,.##")
£10,000,000.00
DEF means "define" and comes along with defining a function in case of DEF FN or defining variables in case of DEFREAL, DEFINT or DEFSTR.
DEF FN must come before using the statement FN.
DEF with a variable declaration should come before using a variable.
(see also FN)
Forces all variables(s) starting with the specified letter(s) to be integer variables. Singular letters could be defined or a range by a minus symbol between two letters.
Examples:
20 DEFINT a-z: sets all variables starting with an A until Z as integer.
or
10 DEFINT F,S ..... (or 10 DEFINT A-Z)
20 FIRST=111.11:SECOND=22.2
30 PRINT FIRST,SECOND:' prints out 111 22
Sets the default for variable(s) with the specified first letter(s) to a floating point figure.
Sets the default for variable(s) with the specified first letter(s) to string(s) variables.
Switch to radians mode for trigonometric functions (SIN, COS...).\ See also: RAD
Deletes the current program completely (without arguments) or only the given line or line range. Even
DELETE -
is legal, it has the same effect as
DELETE
The lines specified do not have to exist, all lines matching the range will be deleted and having no matches does not cause an error.
Disables interrupts until re-enabled by EI command or by RETURN at end of an interrupts service routine.
Creates array a with single or multiple dimensions. You may optionally specify integer (%), real (!) or string ($) type otherwise it defaults to the current type set for the first letter of the array name.
d1 is size of first dimension-1, d2 is size of second dimension-1 and so on. DIM x(10) will create an array with 11 elements, x(0) is the first element, x(10) is the eleventh and last.
You can specify as many dimensions as will fit on one 255 character line, which is a maximum of 125. Trying to create an array that already exists will generate an Array already dimensioned error.
If an array is not specified by DIM before being accessed, each dimension value defaults to 10. The maximum dimensions that can be created this way is three.
NEW: In this interpreter you can resize arrays without destroying the content.
Display 1 program line for editing.
The following keys can be used in editing mode, or during typing in BASIC:
CTRL+CURSOR LEFT - go to start of line
CTRL+CURSOR RIGHT - go to end of line
Draws a line from the current cursor position to position x,y. i1 specifies colour, i2 is the drawing style.
4 drawing styles:
i2 = 0 normal colour
i2 = 1 XOR colour
i2 = 2 AND colour
i2 = 3 OR colour
Draws a line from current graphics cursor position to current cursor x position + xr, current cursor y position + yr. i1 and i2 as DRAW.
Enable interrupts which have been disabled by DI
Indicates end of program
The ENT command define the TONE shape of a sound which means manipulating the frequency in a certain range.
The command could looks like:
ENT NUMBER,STEPS?,VERTICAL?,HORIZONTAL?
It is possible to define 15 different envelope shapes. So NUMBER could be 1-15.
Each ? stands for up to five sections (1-5), where each STEP<>VERTICAL<>HORIZONTAL with the same ? are belong together.
STEP: means how many steps in each section (0-127) > one step is 1/100 of a second!
VERTICAL: means how big is the step size from bottom to top (-128 to 127)
HORIZONTAL: means how big is the step size from left to right (0-255)
The ENV command define the VOLUME shape of a sound which means manipulating the loudness in a certain range.
The command could looks like:
ENV NUMBER,STEPS?,VERTICAL?,HORIZONTAL?
It is possible to define 15 different envelope shapes. So NUMBER could be 1-15.
Each ? stands for up to five sections (1-5), where each STEP<>VERTICAL<>HORIZONTAL with the same ? are belong together.
STEP: means how many steps in each section (0-127) > one step is 1/100 of a second!
VERTICAL: means how big is the step size from bottom to top (-128 to 127)
HORIZONTAL: means how big is the step size from left to right (0-255)
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).
Associated keywords: OPENIN, CLOSEIN
This example reads a file from disc and print it out on screen. Like the "TYPE" command in CP/M
10 OPENIN "text.txt"
20 WHILE NOT EOF
30 LINE INPUT#9,a$
40 PRINT a$
50 WEND
60 CLOSEIN
Erases the specified array(s) or variables and frees the memory used.
Returns the line number of the last error encountered.
Reports the number of the last ERRor encountered.
Take Error action with a given error number.
In Graphic-Mode: chr$(&C3)+chr$(&80). In Text-Mode: chr$($E2)+chr$($82)+chr$($AC) (UTF8-Euro). This is the Euro Sign (new in this interpreter)
BASIC branches to the subroutine at line ln EVERY (reccuring) i/50 seconds. (see also "AFTER i[,t] GOSUB line")
There are 4 delay timers from 0 to 9 (in CPC onlc 0 to 3) which can be specified with <timer number>. If omitted <timer number> defaults to 0.
In the case of parallel task has 3 the highest and 0 the lowest priority.
With DI or EI you can disable or enable the timing interrupt. With REMAIN <timer number> you can also disable an AFTER or EVERY construct and stores the "remaining" time (> REMAIN)
Interrupts run as long as the main loop / program runs, even the main programm is paused > press ESC only once not twice for a break.
It is important to know or realise that low-priority-interrupts which occurs simultanously to higher-priority-interrupts are not lost. Their task remains or handled again after finishing the higher-prio interrupt.10 REM > interrupts
20 EVERY 50,0 GOSUB 100: REM > lowest priority
30 EVERY 100,1 GOSUB 200
40 EVERY 200,2 GOSUB 300:
50 AFTER 1000,3 GOSUB 400: REM > highest priority
60 WHILE flag=0
70 a=a+1:print a
80 WEND
90 END
100 REM #0
110 PEN 2:PRINT "timer 0":PEN 1
120 RETURN
200 REM #1
210 PEN 2:PRINT "timer 1":PEN 1
220 RETURN
300 REM #2
310 PEN 2:PRINT "timer 2":PEN 1
320 RETURN
400 REM #3
410 flag=1:PEN 2:PRINT "no more interrupts..."
420 RETURN
Hint: Timing with interrupts is important, especially if more than one interrupts run. If the interval of a subroutine driven by an interrupt is too long than the processor can never get back to deal the main program again.
FUNCTION: Calculates "e" to the power given in the <numeric expression> (i), where "e" is approximately 2,7182818-the number whose natural logarithm is 1.
Associated keywords: LOG
Example:
PRINT EXP(6.876)
968.743625
Fills an area of a graphics screen i colour i (0-15). Default value of i is the current graphics pen colour.
FUNCTION: Unlike CINT, FIX merely removes the part of the numeric expression, to the right of the decimal point, and leaves an integer result, rounding towards zero.
Associated keywords: CINT, INT, ROUND
Example:
PRINT FIX(9.99999)
9
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>
Example: "with the definition of..."
10 gn=9.80665
20 DEF FNgrv=s0+v0t+0.5gn*t^2
30 s0=0:v0=0:t=5
40 PRINT "...after";t;"seconds your dropped stone falls";FNgrv;"metres"
"the results are..."
:...after 5 seconds your dropped stone falls 122.58315 metres
Creating a counting loop (control strucutre) with a starting condition. Inside the counting loop one or more commands will be executed.
The loop consists of of following specifications:
1. FOR
2. a control variable
3. =
4. starting value
5. TO
6. target value
7. STEP [optional]
8. increment / step size
... instructions between
9. NEXT
control variable [optional]
You have to use the command STEP if you wish to count backwards. It's good to name the control variable after NEXT for readability and better program style.
After each loop the computer checks internaly if the target value has been reached (like an IF ... THEN ... ELSE instruction).
If the target value is reached NEXT closes the loop and calculates another step, so the control variable will be changed last time.
The default STEP value - if not specified - is one (1).
Example:
10 FOR I=1 TO 10
20 PRINT I;
30 NEXT I
40 PRINT I
RUN
1 2 3 4 5 6 7 8 9 10 11
READY
prints the fraction of an number
PRINT FRRACTON$(0.33333333333)
1/3
Smooths character and graphics movement and reduces flicker (waits for a VSYNC signal every 20 ms).
FUNCTION: Establishes how much FREe memory remains unused by BASIC.
Jumps to subroutine which is given as argument.
Example:10 PRINT "Calling subroutine"
20 GOSUB 100
30 PRINT "Back from subroutine"
40 END
100 REM Begin of the subroutine
110 PRINT "Subroutine started"
120 RETURN
Jumps to the line number which is given as argument. Combine the GOTO command with an IF...THEN...ELSE instruction for creating a condition-controlled loop. With this interpreter you can use a variable instead a number, too.
...works only in combination with the command PEN or PAPER to set the plotting/drawing pen or background colour.
If the TAG command is used to set text at the graphics cursor GRAPHICS PEN or GRAPHICS PAPER instead of the regular PEN or PAPERis necessary to colour the text.
displays the help page of all commands of only one <command> or searches for a expression.
Asks for a choice with the IF...THEN...ELSE statement.
IF compares the entry condition in a logical way
THEN contains instruction if the comparison is true
ELSE contains instruction if it's false.Example:
10 INPUT "guess a figure:",f
20 IF f=10 THEN PRINT "right": END: ELSE GOTO 10
In case of nested choices there's a possibility to that with an IF...THEN instruction but not very recommended:10 INPUT "guess a figure:",f
20 IF f=10 THEN PRINT "right": END: ELSE IF f<10 THEN PRINT "too small" ELSE PRINT "too big"
30 GOTO 10Other nested structures like IF...THEN...ELSE...ELSE won't work first because the Locomotive Basic only looks after the first ELSE instruction found and can't execute more single commands as a block
for a certain condition in comparision to e.g. "PASCAL" > begin...end-block, "C" > {...}-block.
After a THEN or ELSE you don't need to type GOTO. The following two examples are the same:
IF -1 THEN GOTO 30 ELSE GOTO 40
IF -1 THEN 30 ELSE 40
FUNCTION: Produces a $tring of HEXadecimal digits representing the value of the <unsigned integer expression>, using the number of hexadecimal digits.
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 be produced in as many digits as are required.
Accociated keywords: BIN$, DEC$, STR$, UNT
Example:
PRINT HEX$(255,4)
00FF
Sets the color with given number to i1. If i2 is given, the color is flashing. Instead color index number (0..28) you can use RGB colors (#123456)
FUNCTION: INterrogates the KEYboard to report which keys are being pressed. The keyboard is scanned every 0.02 (1/50) second.
The function is useful for spotting whether a certain key is down or up, by detecting the returned value of -1 (which occurs regardless of [SHIFT] and [CONTROL] key status).
The example below detects when [SHIFT] and V (key number 55) are pressed together, then ends the program. Refer the manual for the key numbers.
Associated keywords: CLEAR INPUT, INKEY$, JOY
Example:
10 IF INKEY(55)<>32 THEN 10
20 PRINT "You have pressed [SHIFT] and V"
30 CLEAR INPUT
run
The state of [SHIFT] and [CONTROL] in conjunction with the key specified in the <integer expression> is identified as follows:
|Value returned |[SHIFT] |[CTRL] |Specified key |
|-1 |ignored |ignored |up |
|0 |up |up |down |
|32 |down |up |down |
|128 |up |down |down |
|160 |down |down |down |
Hint: instead of the CPC key code you can use a char or string, to see the corresponding key or a stream (e.g. #16 for P or "P") for a PC Linux scan code
FUNCTION: Interrogates the KEYboard, returning the current $string reflecting any key that is pressed.
It provides operator interaction without hitting [ENTER] after every answer.
If there is a key pressed, then the function responds. If no key is pressed, INKEY$ returns an empty string.
FUNCTION: Returns the INPut value from the I/O address specified in the <port number>.
Associated keywords: OUT, WAIT
Reads a value from window or file. If a String is given, this string is printed before. After the string you can either put an ; or , between the string and the variable. If you use a ; then a questionmark is printed after the string
similar to LINE INPUT
FUNCTION: Searches the first <searched string> expression to find the first occurance of the <searched for string expression<, and reports the position of its occurance within the <searched string>.
If the <searched for string> does not occur within the <searched string>, then 0 is reported.
The position at which to start searching the <searched string> is optionally specifiable using the <start position> parameter which must yield an integer number in the range 1 to 255.
Associated keywords: none
Get the integer part of a number. This is to round down a number
at the begining of any line you can label this line with a name to jump to it with GOTO or GOSUB and so on. This is nor a standard Locomotive BASIC command
10 LABEL start
20 PRINT i:i=i+1
30 IF i<4 THEN GOTO start
FUNCTION: Returns the number of characters (in the range 0 to 255) specified in the <required length> parameter (<integer expression>), after extracting them from the LEFT of the <string expression>.
If the <string expression> is shorter than the <required length>, the whole <string expression> is returned.
FUNCTION: Returns the total number of characters (i.e. the LENgth) of the <string expression>.
See SIZEOF
Was used to define variables. You don't need to use the LET command because it is just a command which was added for compatibility reasons.
Reads a line as a whole string from window or file. If a String is given, this string is printed before. After the string you can either put an ; or , between the string and the variable. If you use a ; then a questionmark is printed after the string
similar to INPUT
A command for listing the Basic program code.
Possibility for manipulating display is using line numbers with a minus symbol.
Example:
LIST 100-
List every line after line number 100.
LIST -100
List every line until line number 100 has reached.
LIST 100-200
List every line between line number 100 and 200 included
With the help of separate window definitions it is possible to print out long listings, better differentiate parts / slices of it into different window predefined
Example:
LIST 1000-1100,#1
LIST 3000-3100,#2
...prints out two parts of one program out into two windows (if they are defined well)
With this directive you may load any file in memory
Basic files (extension .bas) are loaded in Basic memory, you cannot choose loading address
Moves the text cursor to the x,y location.
x starts at 1 on the left and goes up to 20 (in mode 0), 40 (in mode 1) or 80 (in mode 2).
y starts at 1 at the top and ends at 25 at the bottom.
FUNCTION: Calculates the natural LOGarithm (base of e) of <numeric expression> which mustbe greater than zero.
FUNCTION: Calculates the logarithm (base of 10) of <numeric expression> which mustbe greater than zero.
FUNCTION: Returns a new string expression which is a copy of the specified <string expression> but in which all alphabetic characters in the range A to Z are converted to lower case.
Useful for processing input where the answers may come in mixed upper/lower case.
Associated keywords: UPPER$
Sets bits in each adjacent group of 8 pixel on (1) or off (0) according to binary value of i1 (0-255). i2 determines whether the first point of the line is to plotted (1) or not (0).
Example:
10 CLG 2:MASK 1:MOVE 0,0:DRAW 500,400
20 MASK 15:MOVE 0,0:DRAW 500,400
FUNCTION: Returns the MAXimum value from the <list of: numeric expressions>
You don't need to use the command because it is just a command which was added for compatibility reasons.
With the MID$ command there are two applications possible:
MID$ creates a new substring out of the give <string> and starts at the defined position <start position> and print the number of given characters by <length of substring>.
If no length is defined every character from <start position> will be printed out.
If a higher value of <start position> or <length of substring> than the real length of the initial string is defined a blank string will be printed.
The range of <start position> or <length of substring> is from 0 up to 255 characters.
With MID$ you're able to manipulates given strings by inserting a new string.
Take care of the two different applications and using in BASIC. The optional last parameter does not exist in original Locomotive Basic. if this parameter is -1 (true) the part of the first string will be replaced with the replacement string, inimportant how long it is.
Example for the 1. application:
10 a$="Hello"
20 PRINT MID$(a$,2,2)
run
el
Ready
Example for the 2. application
10 a$="Hello"
20 MID$(a$,2,3)="ipp"
30 PRINT a$
run
Hippo
Ready
FUNCTION: Returns the MINimum value from the <list of: numeric expressions>
Changes the screen mode: MODE 0 is 160×200 in 16 colours, MODE 1 is 320×200 4 colours, MODE 2 is 640×200 2 colours and MODE 3 is 640×400 in 4 colours. (only text mode in the GUI, graphic mode is always 640x400)
When x,y is given, the resolution is set to x,y - so you can use a larger or smaller window than in original CPC.
Moves the graphic cursor to position x,y. The parameter i1 may be used to change the pen (drawing) colour. The parameter i2 specifies the logical colour, as in DRAW.
4 drawing styles:
i2 = 0 normal colour
i2 = 1 XOR colour
i2 = 2 AND colour
i2 = 3 OR colour
moves the graphic cursor (relative) from current position to current cursor x position + xr, current cursor y position + yr. i1 and i2 as in MOVE.
Clears BASIC RAM which means program and variables. Keeps symbol defintion (if defined) and screen mode without clearing.
ON BREAK CONT
Prevents the interruption of program execution by the ESC key.
ON BREAK GOSUB ln
Passes control to subroutine at line ln when ESC ESC pressed.
ON BREAK STOP
Restores normal function of ESC key during program execution.
ON ERROR GOTO ln
Passes the control to line ln if an error is detected in the program.
ON ERROR GOTO 0
Turns of the error trap, and restores normal error processing.
ON variable GOTO ln x1, x2, x3, x4, ...
In case of passing more choices ON variable GOTO ln x1, x2, x3, x4, ... points to a table with the jumping target.
Example:
10 PRINT "1. LOAD - 2. SAVE - 3. EXIT"
20 INPUT choice
30 ON choice GOTO 1000, 2000, 3000
40 CLS: GOTO 10
1000 PRINT "1. LOAD":END
2000 PRINT "2. SAVE":END
3000 END
In case that the variable choice won't fullfil the condition (in a range between line 0 and 65535) the next instruction will be executed (here: Line 40). If "choice" is smaller than 0 an error will occur.
ON variable GOSUB ln x1, x2, x3, x4, ...
In case of passing more choices targeting to SUBROUTINES ON variable GOSUB ln x1, x2, x3, x4, ... points to a jumping table. If the number is too large, the program continues normally.
Opens the specified data file for reading. It has to be an ASCII file. (The command CLOSEIN closes reading data file.) Read from the file using INPUT #9
Opens the specified data file for writing. It writes an ASCII file. (To close writing use the command closeout.)
The command defines the origin (world reference point) for the graphics coordinate system. Normally the reference origin is in the left, bottom corner of the default screen and has 0,0.
So the most left coordinate value could be by default 639 and the most top value 399. Independent from the actual modus (2, 1 or 0) the range for the x coordinate are always 640 points and for the y coordinate 400 points.
In theory you are able to address 256,000 pixel but only 128,000 are visible due to the maximal resolution of the hardware.
x,y are the the new coordinates for the 'world reference'.
l,r,t,b are optional and set the borders for the new graphical window (works in the same way like the WINDOW command for a text window). l,r,t,b means left, right, tob and bottom coordinates.
If a new graphical window (borders) is defined every point or drawn line won't be plotted (clipped internally).
Example (the line drawn will be cutted):
ORIGIN 320,200,250,450,100,300
DRAW 0,200
Sets the value to the I/O address specified in the <port number>.
Associated keywords: INP, WAIT
sets the background color
sets the text color
Plots a point at the graphic cursor to position x,y. The parameter i1 may be used to change the pen (drawing) colour. The parameter i2 specifies the logical colour, as in DRAW.
4 drawing styles:
i2 = 0 normal colour
i2 = 1 XOR colour
i2 = 2 AND colour
i2 = 3 OR colour
Plots a point at the graphic cursor (relative) from current position to current cursor x position + xr, current cursor y position + yr. i1 and i2 as in MOVE.
FUNCTION: Reports the current horizontal POSition of the text cursor relative to the left edge of the text window. The <stream expression> MUST be specified, and does NOT default to #0.
POS(#8) reports the current horizontal carriage position for the printer, where 1 is the extreme left hand edge.
POS(#9) reports the logical position in the disc file stream, i.e. the number of printing characters sent to the stream since the last carriage return.
prints content to the screen. If it ends with an ;, there will be no new line at the end.
Within the command a ; or <space> lets print the next operand, with a comma (,) the cursor will be set to the next tab position (defined with ZONE)
stream#8 is the printer
stream#9 is the disc.
SPC(<count>) prints count spaces
TAB(<position>) sets the cursor to the correct x-position.
See USING command.
Do not forget the separator (e.g. space or semikolon) after a string. PRINT "TEST"SPC(2) without separator does not work!
same as PRINT
Switch to radians mode for trigonometric functions (SIN, COS...).\ See also: DEG
Resets the pseudo-random generator. The optional parameter TIME does nothing and is implemented because of compatbility issues.
Gets the next data item (from DATA commands), stores it in the given variable and moves to the next item.
The variable must be of the correct type.
See also: DATA, RESTORE
Draws a rectangle on the screen
Remark without any operation. The rest of the line is handled by this command.
same as REM
Releases a sound which was hold on (by a SOUND command) before. It uses the same bit matrix like the SOUND command for the first parameter
(&x00000001) releases chanel A
(&x00000010) releases chanel B
(&x00000011) releases chanel A and B
(&x00000100) releases chanel C
(&x00000101) releases chanel A and C
(&x00000110) releases chanel B and C
(&x00000111) releases chanel A, B and C
Example:
10 SOUND 65,1000,100
20 PRINT"PRESS R TO LET IT SOUND"
30 IF INKEY(50)=-1 THEN 30
40 RELEASE 1
Renumbers the lines of the current program or range.
By default, the whole program is renumbered starting at line 10 with multiples of ten. Any parameter that is left out defaults to 10. It is important to note that jumps (GOTO, GOSUB and the like) are automatically converted to the new line numbers.
The whole set of parameters can be used to renumber only the last part of a program.
Defines a loop with UNTIL <expression>. The loop continues, until the expression is true. This is not a standard Locomotive command.
10 i=0
20 REPEAT
30 PRINT i:i=i+1
40 UNTIL i>=3
0
1
2</expression>
FUNCTION: replaces all occourence of <search-string> with <replace-string> in the given <string>. This function does not exist in original BASIC.
Resets the data pointer used by READ. When used without parameters, resets the pointer to the first data in the program. Otherwise, resets the pointer to the given line number.
Command causes the program to resume after an error code and if it is interrupted by an ON ERROR GOTO jump
So it can either resume
(if there is no line number stated) at the same line after error code (and if there are more statements in one line)
or
at the line number stated (optional)
or
with the NEXT parameter (optional) ... at the line followed by the error line
Terminates a subroutine and returns control to the line following the GOSUB call (see GOSUB)
FUNCTION: Returns the number of characters (in the range 0 to 255) specified in the <integer expression> (=required length) parameter, after extracting them from the RIGHT of the <string expression>.
If the <string expression> is shorter than the <integer expression>, the whole <string expression> is returned.
FUNCTION: Returns the next RaNDom number in sequence if the <numeric expression> has a positive value or is not specified.
If the <numeric expression> yields a value of zero, RND returns a copy of the last random number generated.
Associated keywords: RANDOMIZE
1. Example:
PRINT RND(0)\”0.536703827
Ready
PRINT RND(1)
0.271940658\”Ready
PRINT RND(0)
0.271940658
Ready
2. Example:
Example for generating an integer random number between 1 and 1000
10 A=INT((RND(1)1000)+1)
20 PRINT A
30 GOTO 10
3. Example:
For generating a random number between a lower and higher border
10 INPUT "Low border",low
20 INPUT "High border",high
30 A=INT(RND(1)(high-low))+low
40 PRINT A
4. Example:
10 RANDOMIZE\”20 FOR x=1 TO -1 STEP -1
30 PRINT "rnd parameter=";x
40 FOR n=1 TO 6
50 PRINT RND(x)
60 NEXT n,x\”run
FUNCTION: Rounds <numeric expression> to a number of decimal places or to the power of ten specified by <integer expression>.
If <integer expression> less than zero, the <numeric expression> is rounded to give an absolute integer with <integer expression> number of zeros before the decimal point.
Associated keywords: ABS, CINT, FIX, INT
Runs the current program, optionally starting at a given line. If no line number is given, starts at the first line.
If a string is used after RUN command a programm will be loaded and executed from storage medium (e.g. Tape, Disc). With that command protected BASIC programs can be executed.Example:
RUN"disc"
Command saves the current BASIC program / content from RAM onto a storage medium (e.g. Tape, Disc)
FUNCTION: Calculates the Real value for the Sine of <numeric expression>, defaulting to the Radian (RAD) measure mode unless otherwise declared by a DEG command.
Gets the size (number of rows) of an array
10 DIM a$(15),b(4,4)
20 PRINT SIZEOF(a$),SIZEOF(b)
RUN
16 25
FUNCTION: Determines the SiGN of the <numeric expression>. Returns -1 if <numeric expression> is less than 0, returns 0 if <numeric expression> = 0, and returns 1 if <numeric expression> is greater than zero.
SOUND does only work with running and connected CPCmonitor!
the SOUND command has following shape:
SOUND Channel,Period,Duration,Volume,Volume-Envelope,Tone-Envelope,Noise
C: Selecting channel is done bitwise (combinations are possible of course):
(Bit 0) &x00000001 = 1 = channel A (middle)
(Bit 1) &x00000010 = 2 = channel B (left)
(Bit 2) &x00000100 = 4 = channel C (right)
more function about channel are
(Bit 3) &x00001000 = 8 = Rendezvous with channel A
(Bit 4) &x00010000 = 16 = Rendesvous with channel B
(Bit 5) &x00100000 = 32 = Rendesvous with channel C
(Bit 6) &x01000000 = 64 = Hold
(Bit 7) &x10000000 = 128 = Flush
P: the period number can be a figure between 0 and 4095 (2^12-1... 12 means that we have 12 tones (inclusive half-tones) in nine octaves on the CPC in sum and their distance between is the twelves square root of two), where 8 octaves are available. E.g. Octave 0 starts on middle C with number 478.
To calculate the period you can use following formula: period=1,000,000/(16*frequency) or in short period=(62,500/frequency)
(e.g. the note "A" with the frequency 440 Hz has the period 142 on the CPC)
In This emulator you can use strings containing the tone name, e.g.
t$="db5":SOUND 1,c,25:SOUND 1,d,25:SOUND 1,t$,25:SOUND 1,db5,25:SOUND 1,"db5",25:REM the last three are the same
D: the duration of the note is measured in 1/100th of a second and can be any positive number in the range 1-32,767. 0 and negative number are in combination with ENT and ENV commands usefull. A negative number means repititions.
V: the volume number range from 0-15 on a CPC664/6128
ENV: and ENT: For shaping the sound ENV (Volume) and ENT (Frequency) commands are available. The relation between SOUND and those commands comes with a figure between 1 to 15 for ENV (5th parameter) and 1 to 15 for ENT (6th parameter).
N: the seventh parameter can be used for blending in noise between the range of 0-15 (BASIC 1.0) or 0-30 (BASIC 1.1). The higher the number the 'deeper' or 'dirty' is the noise.
in conjunction with PRINT the SPC command prints out a certain number (n) of spaces.
Example:
PRINT "Hello";SPC(10);"World";
Hello World
SPEED INK command defines the frequency of colour changes if a colour change was defined. The duration is calculated by n1=... or n2 =duration/50 seconds
SPEED KEY command defines the delay after which a key repeat (for keys that do repeat). The first parameter is the delay before the first repeat and the second parameter is the delay between further repeats. Delay is in 1/50th of seconds.
SPEED WRITE command sets the speed in baud to write on tape (or the wav-file). 0=1000 Baud, 1=2000 Baud, 2=4000 Baud, 3=8192 Baud.
FUNCTION: Returns the SQuare Root of the specified <numeric expression>.
Associated keywords: none
Example:
PRINT SQR(9)
3
Gets <count> spaces
Redefines the appearance of the character at index n.
Each of the following eight integers defines the contents of one pixel row, starting at the top of the character.
Each character fits in an 8x8 pixel grid.
Missing lines are considered as empty.
Example:
SYMBOL 255,255,129,129,129,129,129,129,255
PRINT CHR$(255)
Defines character 255 to look like an empty square and prints it.
no operation, only for compatibility.
Breaks program execution at line containing the STOP statement. The message BREAK in is output with the line number.
FUNCTION: Converts the <numeric expression> to a decimal STRing representation.
Useful for converting a number to a string in case of string manipulation. E.g. after converting a figure to a string then the most left character holds the sign: a minus in case the figure is negative and a space in case the figure is positiv.
Associated keywords: BIN$, DEC$, HEX$, VAL
Example:
10 FIGURE=-1599
20 FIGURE$=STR$(FIGURE)
30 PRINT FIGURE$
-1599
FUNCTION: Returns a string expression consisting of the <character specifier> repeated the number of time (in the range 0 to 255) specified in the <length>.
Associated keywords: SPACE$
WINDOW SWAP works in combination with the window command. Every error or status messages from the operating system will be displayed normaly on WINDOW#0 (=main window). WINDOW SWAP changes the main window to the desired target window.
Example (if a window with number 4 was defined before...):
WINDOW SWAP 0,4
SWAP <var1>,<var2> swaps the content of two variables (no standard BASIC)
in conjunction with PRINT the TAB command sets the x position of the cursor to the given position
Example:
PRINT "Hello";TAB(10);"World";
Hello World
in conjunction with PRINT the TABDOT command sets the decimal point of the value to x position of the cursor to the given position
Example:
PRINT "Hi";TABDOT(10,123.45,2);"World";
Hi 123.45
THIS COMMAND DOES NOT EXIST IN THE ORINAL LOCOMOTIVE BASIC!
Allows text to print at graphics cursor position. (#st does not work, yet).
see TAGOFF
Directs text to stream st printing it at previous text cursor position. (#st does not work, yet)
FUNCTION: Calculates the TANgent of the <numeric expression>, which must be in the range -200,000 to +200,000.
NOTE: DEG and RAD can be used to force the result of the calculation to degrees or radians respectively.Associated keywords: ATN, COS, DEG, RAD, SIN
Example:
PRINT TAN(45)
1.61977519
FUNCTION: Moves the graphics cursor to the absolute position specified by the <x> and <y co-ordinate>s, and reports the value of the ink at the new location.
Associated keywords: MOVE, MOVER, TESTR, XPOS, YPOS
FUNCTION: Moves the graphics cursor by the amount specified in the <x> and <y offset>s relative to its current position, and reports the value of the ink at the new location.
FUNCTION: Reports the elapsed time since the computer was last switched-on or reset, (excluding periods when reading or writing to disc).
Each second of real time is equal to the returned value = TIME/300.
gives the actual date/time either in hh:mm:ss format or in the given format
Not in original BASIC: removes spaces from the ends of a string
Turns off the program flow trace (see TRON)
FUNCTION: Return an integer in the range -32768 to +32767 which is the twos-complement equivalent of the unsigned value of the <address expression>.
Example:
PRINT UNT(&FF66)
-154
REPEAT:UNTIL... loop: see HELP REPEAT. This is not a standard Locomotive command.
Turns on the program flow trace for debugging. Causes the line number of each statement executed to be displayed.
FUNCTION: Returns a new string expression which is a copy of the specified <string expression> but in which all alphabetic characters in the range A to Z are converted to UPPER case.
Useful for processing input where the answers may come in mixed upper/lower case.
Associated keywords: LOWER$
PRINT USING makes it possible to define the print format of an expression transmitted by the command PRINT. One defines for that the <format model> with which one wishes to appear the expression. One uses as <separator> either a comma, or a semicolon. The <format model> is a character string made up with the following « field indicators »:
Numericals formats
In a number:
Example: ######
. Indicate the site of the decimal point (equivalent with our comma).
Example:######.##
, (Reserve a space). This sign, being able to appear only immediately before the decimal point, indicates that the figures located on the left of the decimal point will be laid out by groups of three (corresponding to the thousands) separate between them by a comma Example:######,.##
Framing of a number:
££ (Reserve two spaces). Indicate that the sign £ will appear immediately before the first digit or the decimal point, i.e. on one of the sites reserved for digits.
Example: ££######,.##
** (Reserve two spaces). Indicate that all the empty spaces located before the number will be filled by asterisks. Example: ######,.##
£ (Reserve three spaces). Add the options ** and ££, i.e. the asterisks at the head and the sign £ preceding immediately the number.
Example: £######,.##
$$ (Reserve two spaces). Indicate that the sign $ will appear immediately on the left than the first digit or decimal point, i.e. on sites reserved to digits.
Example:$$######,.##
$ (Reserve three spaces). Add the options ** and $$, i.e. the asterisks at the head and the sign $ preceding immediately the number.
Example: **$######,.##
FUNCTION: Returns the numeric VALue, (including any negative sign and decimal point) of the first character(s) in the specified <string expression>.
FUNCTION: Reports the current vertical POSition of the text cursor relative to the left edge of the text window. The <stream expression> MUST be specified, and does NOT default to #0.
Wait until any key is pressed. Originally: Waits until the I/O port at add returns a value (0-255). The value returned is XORed with i2 and the ANDed with i1. This is repeated until a non-zero result occurs.
repeats this loop until the expression is false
The WIDTH command defines the maximum number of characters per output line for a specific stream.
Once the specified width is reached, Locomotive BASIC automatically inserts a carriage return (line break). This prevents long lines from being truncated or wrapping incorrectly on the printer or screen.
It is most commonly used with the printer (stream #8), but can also be applied to the screen (stream #0) or any other open stream.
It is possible to define in BASIC eight (8) independent windows for text output. Overlapping is possible.#STREAM: eight window are possible. No. zero (0) is the main window where error or status messages were put out by default.
each position is included inside the windowL = left column / R = right column (dependent of the mode 0 = 20 / 1 = 40 / 2 = 80)
T = top row / B = bottom row (always from 1 to 25)
Example:
MODE 1
WINDOW#1,1,40,1,6
...defines the first top quarter of the screen for window No. 1
===> if R or B has value of 999, this means the maximum size of the console screen! <===
The same as PRINT, but strings are printed in ""
10 a$="Hello"
20 WRITE 100,a$
RUN
100 "Hello"
FUNCTION: Reports the current horizontal (X)POSition of the graphics cursor.
FUNCTION: Reports the current vertical (Y)POSition of the graphics cursor.
Changes the width of the print zone. Default is 13.
Example:
10 MODE 2
20 PRINT"normal zone (13)"
30 PRINT 1,2,3,4
RUN
normal zone(13)
1 2 3 4
Ready
20 PRINT"now with different zone(5)"
30 ZONE 5
40 PRINT 1,2,3,4
RUN
now with different zone(5)
1 2 3 4
Ready
creates a bitmap in base64-format to insert into an img-html-tag (<img src="data:image/png;base64,Base64String alt="Embedded Image"/>) from the screen. You can use a rect of the screen. If bmp=-1 then the bitmap is not encoded as base64 to realize a bitmap download
Same as CAT
Files are written to disc, not to tape.
Changes the screen mode without clearing the screen: MODE 0 is 160×200 in 16 colours, MODE 1 is 320×200 4 colours, MODE 2 is 640×200 2 colours and MODE 3 is 160×200 in 4 colours.
In a Webserver environment prints the very first header before <html> and new cookie declarations.
In a Webserver environment this command reads all COOKIE variables and stores them in the corresponding string variables with the same name.
e.g. 10 |COOKIE
20 PRINT foo$
test
Ready
In a Webserver environment this command reads all GET variables and stores them in the corresponding string variables with the same name.
Hint: requesturi$ is set to the active url.
e.g. <input name="foo" value="test" />
...
10 |GET
20 PRINT foo$
test
Ready
execte CPCdisplay[.exe] to communicate with it. CPCdisplay shows all the graphics and plays sound, which the terminal cannot do. (Show |SIXELMODE)
|JSON Command Reference
Path examples:
kunden[3].name
kunden[0].hobbies[2]
kunden[-1]
loads the previosly saved BASIC environment.
plase refer |SQLITE for details. |MYSQL works exactly identically, but to connect to have to use it in this way:
|MYSQL CONNECT "localhost;meinuser;meinpass;meinedb"
Saves the complete BASIC Environment (program, variables) to default.basicsh.json
In a Webserver environment this command sets a COOKIE variables and stores it in the buffer. |HTMLSTART makes it permanent.
e.g.: |SETCOOKIE,"foo","content",60
THIS COMMAND MUST BE USED BEFORE |HTMLSTART!
prints the number of parameters or puts it into <variable>
prints the given parameter to screen or puts it into the <variable>
prints the graphics screen (sixel-Format) to the console
Slows down the output on the text screen in ms, to simulate the slow output of a original CPC
Switches to the graphic mode in the console. In a UNIX environment sixel MUST be installed to show the sixel graphics! With kolsole (KDE) or 'xterm -ti vt340' it should work.
prints a list of all variables
Shows all FOR and WHILE Loops for debugging issues
debugging issue: show detected keyboard
Lists all possible POSIX Shell commands
Use of a SQlite database
|Create or open an database:
|SQLITE CONNECT <database name>
Executes an query:
|SQLITE QUERY "create table test(name:varchar(255))"
or to put a result into an array a$:
|SQLTE QUERY "select * from test",a$
Close the database:
|SQLITE CLOSE
Example:
10 |SQLITE CONNECT "zl.db"
20 |SQLITE QUERY "create table test(name varchar(80))"
30 |SQLITE QUERY "insert into test (name) values (""Klaus""),(""Xaver""),(""Anton""),(""Dietmar"")"
40 |SQLITE QUERY "select * from test order by name",a$
50 FOR i=0 TO SIZEOF(a$)-1
60 PRINT a$(i)
70 NEXT
90 |SQLITE CLOSE
Files are written to a wav file in Amstrad CPC Tape format
Switches back to text only mode. If mode parameter is given, the Text mode is set to this (See MODE) and the Text or Graphic mode will not change.
Set the SOUND Waveform. 0=wfSine, 1=wfSawtooth, 2=wfSquare, 3=wfOragn. Standard is wfSquare. This parameter will not reset when basic resets.
Any command that is not part of the BASIC language will be passed to the operating system for execution. If it fails, you get a "Syntax error".
Dezimal: 123
Hexadezimal: &C9
Binär: &x10101001
Exponential: 3.2e4 = 32000
TRUE=-1, FALSE=0
Der Normale ASCII-Zeichensatz des Schneider CPC wurde implementiert, jedoch im grafischen Textmodus werden die UTF8-Zeichen für die deutschen Umlaute äöüÄÖÜß korrekt umgesetzt.
ein doppeltes "" im String wird dann als CHR$(34) umgedeutet, um die Eingabe zu vereinfachen.
Mit der Taste "Einfg" (insert) wird im Grafikmodus das unter dem Cursor liegende Zeichen kopiert (COPY beim CPC)
Wenn die Kommandozeile mit +,-,*,/,^,= anfängt, so wird das letzte numerische Ergebnis vorangesetzt und mann kann sich das PRINT sparen. Damit Kann die Shell leichter als Taschenrechner verwendet werden
Der Operator = am Anfang bewirkt somit das gleiche wie PRINT, das Ergebnis wird aber nicht in dezimalschreibweise, sondern als Bruch ausgegeben.