A Comparision of Keywords on the Camputers Lynx and the ZX Spectrum
Overview
The following is a list of keywords, operators and delimiters used on the Camputers Lynx microcomputer and the ZX Spectrum.
Released in 1983, the Camputers Lynx shared features with many of the microcomputers around at the time. Among the features to be found on the Lynx are structured BASIC statements such as REPEAT..UNTIL and WHILE..WEND, PAPER and INK statements which use the same colour codes as the Spectrum, and the ability to store machine code data within a BASIC program.
Commands
Keyword
Meaning
Comments
APPEND
See MERGE
CALL
CALL m[,v]¦LCTN (n) (Lynx)
Result: Calls a machine code subroutine at memory location m and optionally passes the value of the HL register pair to variable v, or calls machine code from LCTN (n) where n is a line number with the program listing. (Lynx)
Not on the Spectrum. Use USR instead to call machine code.
Note: The Spectrum, by default, passes the value of the BC register pair to the USR function, not HL.
See also: CODE (Lynx), LCTN, HL, USR.
CLEAR
CLEAR [n] (ZX Spectrum)
Result (ZX Spectrum): Clears the screen, deletes all variables, resets PLOT and PRINT positions and clears the GOSUB stack. If a number is specified then RAMTOP is lowered to n.
Not on the Lynx, RESERVE performs a similar task.
CONT or CONTINUE
CONT (Lynx)
CONTINUE (ZX Spectrum)
Result: After ESC is pressed (Lynx)
or
After BREAK* is pressed (ZX Spectrum)
CONT or CONTINUE will execute the next line after the error occurred.
*The reportL (BREAK into program) occurs on the ZX Spectrum when BREAK is pressed whilst a program is running.
CONTINUE is shortened to CONT on the Lynx. The ZX Spectrum keyboard shows CONTINUE as CONT.
LIST
LIST (Lynx and ZX Spectrum)
Result: Display complete program listing.
LIST n (ZX Spectrum)
Result: Display program listing from line n or line 0 where no line number specified.
LIST n (Lynx)
Result: Display single program line n.
LIST m,n (Lynx)
Result: Display program listing from line m to line n inclusive.
See also LLIST
LLIST
LLIST (Lynx and ZX Spectrum)
Result: Send a complete program listing to the printer.
LLIST n (ZX Spectrum)
Result: Print the program listing from line n or line 0 where no line number specified.
LLIST n (Lynx)
Result: Print single program line n.
LLIST m,n (Lynx)
Result: Print program listing from line m to line n inclusive.
See also LIST
LOAD (ZX Spectrum)
MLOAD (Lynx)
LOAD "" (ZX Spectrum)
Result: Load the first program encountered on cassette. Double quotes may be replaced by a string variable as long as it is a null string.
LOAD f (Lynx & ZX Spectrum)
Result: Load program f.
LOAD f DATA () (ZX Spectrum only)
Result: Load array f from cassette into the variables area of memory.
LOAD f CODE [m[,n]] (ZX Spectrum)
MLOAD f (Lynx)
Result: Load data from cassette into the memory location specified when the file was saved. If m is specified then load into memory location m. Optionally n (number of bytes to load) may also be specified)
Note: The Lynx does not require any parameters for loading or saving machine code and appears to be used with the built-in monitor program.
LOAD f SCREEN$ (ZX Spectrum only)
Result: Load screen data into from tape directly into the display file (same as:LOAD f CODE 16384,6192 )
The Lynx has limited options for loading programs and machine code compared to the Spectrum, this is possibly overcome by using the built-in monitor program.
MERGE (ZX Spectrum)
APPEND (Lynx)
MERGE f (ZX Spectrum)
Result: Merge program f with that already in memory overwriting duplicate program lines.
APPEND f (Lynx)
Result: Joins a second BASIC program to the end of a previously loaded program. Line numbers in the second program must be higher than the largest line number in the first program.
The Lynx's APPEND statement is similar to the Spectrum's MERGE but whereas MERGE will overwrite duplicate line number the Lynx will not.
MON
MON (Lynx)
Result: Starts machine code monitor.
Not on the ZX Spectrum, third party software can perform this function.
NEW
NEW
Result (Lynx): Erases program.
Result (ZX Spectrum): Deletes program and variables and memory up to and including the address held in the system variable RAMTOP.
Similar on both micros. On the ZX Spectrum NEW preserves the system variables UDG, P-RAMT, RASP and PIP.
RESERVE
RESERVE n (Lynx)
Result: Moves the stack (presumably to n) to allow room for machine code programs.
Not on the Spectrum. CLEAR performs a similar task.
See also CLEAR
RUN
RUN [n] (Lynx, & ZX Spectrum)
Result (ZX Spectrum): Perform CLEAR and GO TO line n (or line 0 if n not specified).
Result (Lynx): GOTO line n (or line 0 if n is not specified).
Similar on both micros.
RUN on the ZX Spectrum clears the screen.
If line n does not exist on the Spectrum, the next valid line number will be executed.
SAVE
SAVE f [LINE m] (ZX Spectrum)
Result: Save program f to tape. If LINE is specified then RUN program from line m once loaded (ZX Spectrum)
SAVE f[,n] (Lynx)
Result: Save program f to tape. If n is specified program will run automatically from line n when loaded (Lynx). SAVE f DATA α[$]() (ZX Spectrum)
Result: Save array α to tape. SAVE f CODE m,n (ZX Spectrum)
Result: Save code from memory to tape starting at address m with a length of n bytes. SAVE f SCREEN$ (ZX Spectrum)
Result: Save display file with filename f to tape (same as SAVE f CODE 16384,6192).
On the Lynx, machine code can only be saved via the monitor program.
See also LOAD, MLOAD, MON, TAPE, VERIFY.
SPEED
SPEED n (Lynx)
Result: Changes speed of program execution. n is a value between 0 and 255 with zero being normal speed. The higher the value n the slower the program executes.
Not on the ZX Spectrum as it only runs at one speed. The SPEED command was tested on the Jynx Emulator.
VERIFY
VERIFY f (Lynx and ZX Spectrum)
VERIFY f DATA α[$]() (ZX Spectrum)
VERIFY f CODE [m[,n]] (ZX Spectrum)
VERIFY f SCREEN$* (ZX Spectrum)
*This command will be accepted by the Spectrum but taped SCREEN$ code will fail verification.
Result (ZX Spectrum): Compares program/array/code, with filename f, from tape with that in memory. Error R if verify fails.
Result (Lynx): Compares program, with filename f, with that in memory. 'Bad Tape' message if an error occurs.
Only program files may be verified on the Lynx.
Statements
Keyword
Meaning
Comments
AT (ZX Spectrum)
PRINT@ (Lynx)
PRINT AT x,y; (ZX Spectrum)
INPUT AT x,y; (ZX Spectrum)
Result: Changes PRINT or INPUT position to x,y.
PRINT@x,y ... (Lynx)
Result: Start PRINTing from text cursor position x,y.
See also PRINT.
BEEP
BEEP x,y (ZX Spectrum)
Result: Sound emitted for x seconds at pitch y.
BEEP x,y,z (Lynx)
Result: Sound emitted for y cycles at wavelength x and at volume z.
BORDER
BORDER m
Result: Changes screen border colour to m.
It is not possible to change the border on the Lynx.
BRIGHT
BRIGHT n
Result: When n=1 permanent brightness is turned on. When n=0 permanent brightness is off.
keywordBRIGHT n
Result: When n=1 temporary brightness is turned on. When n=0 temporary brightness is off.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements. When BRIGHT is applied to the keyword LPRINT there will be no effect on characters printed on the ZX Printer.
The brightness of the screen cannot be changed on the Lynx.
CCHAR
CCHAR &h1h2 (Lynx)
Result: Changes the two characters which make up the flashing cursor. The code to change the cursor is made up of an ampersand (&) followed by two 2-digit hexadecimals each representing an ASCII character. Note the lack of a space between the first 2-digit hex number and the second.
Not on the Spectrum though the cursor can be changed by altering the system variable MODE (23617). A word of caution, altering MODE changes the mode of input (i.e. CAPS, GRAPHICS, etc.) as well as the character representing the cursor.
CFR
CFN n (Lynx)
Result: Changes the flashing rate of the cursor.
n=1 is the fastest
n=65535 is very slow
n=0 is the slowest
The rate of flashing of the ZX Spectrum standard input cursor is fixed in hardware.
CIRCLE
CIRCLE [c;]x,y,z (ZX Spectrum)
Result: Draws a circle subject to colour items (c), of radius z at position x,y.
Not on the Lynx, other methods to draw a circle must be used.
CLOSE #
CLOSE #stream_number (ZX Spectrum)
Result: Close device / stream.
Not on the standard Lynx.
CLS
CLS (Lynx and ZX Spectrum)
Result: Clears the screen and sets the current background colour and foregraound (PAPER and INK). On the Lynx the cursor is set to the home position. On the Spectrum the PRINT and PLOT positions are both set to 0,0.
Similar result all round.
CODE
(Lynx statement)
CODE h1 h2 h3 ... hk (Lynx)
Result: Stores a line of hexadecimal digits for recall by a CALL statement. Digits may be from 00 to FF and must be seperated by spaces.
This is not the same as the Spectrum CODE function.
The easiest way to simulate the Lynx's CODE statement is to place the decimal equivalent numbers into DATA statements and then READ these data into the required addresses using the POKE statement.
See also CALL, LCTN, POKE, USR.
COPY
COPY (ZX Spectrum)
Result: Sends the contents of the screen to the ZX Printer.
Not on the Lynx.
The Lynx does have the statement LINK which simultaneously sends information to screen and printer, but this is not the same as COPY.
See also LINK, LLIST, LPRINT.
DATA
DATA e1,e2,e3, ...
Result: Stores data in a list.
Similar on both micros. The ZX Spectrum requires string data to be surrounded by quotes, the Lynx requires string quotes to be absent.
See also READ, RESTORE.
DEF FN
DEF FN α([α1[,...,αk]])=e (ZX Spectrum)
Result: Defines a function. α and α1 to αk can be a single letter or single letter followed by $ for a string argument.
Definable functions are not available on the Lynx.
DIM
DIM α1(n)[,α2(n),...,αk(n)] (Lynx)
Result: Sets up one or more numeric dimension arrays where α is the variable name and n is the highest subscript (if n=5 then 6 subscripts for zero to 5 will be created).
DIM α[$](n1,...,nk) (ZX Spectrum)
Result: Sets up an array of numbers or characters with k dimensions. For numeric arrays all values are set to zero. In the case of a string array all values are set to SPACE (CHR$ 32).
The Lynx can only handle single dimension numeric arrays, these arrays have a base of zero rather than a base of 1 like the Spectrum.
String arrays on the Lynx do not appear to work although they are accepted by the interpreter.
See also: LET.
DPOKE
DPOKE m,n (Lynx)
Result: Load a 16 bit word (n) into memory addresses m and m+1.
DPOKE can be acheived on the Spectrum with the following code:
POKE m,n-256*INT(n/256)
POKE m+1,INT(n/256)
See also: DPEEK, PEEK, POKE.
DRAW
DRAW x,y (Lynx)
Result: DRAW a high resolution line from the current hi-res position to coordinate x,y.
DRAW [c;]x,y[,z] (ZX Spectrum)
Result: DRAW a high resolution line from the current PLOT position moving x horizontally and y vertically rotating through angle z if third parameter is specified.
DRAW on the Spectrum uses the relative coordinate system, whilst the Lynx uses the absolute coordinate system.
END
END (Lynx)
Result: Terminates program and returns control to the user. CONT will not continue program. (Lynx)
Not on the Spectrum. STOP may be used instead.
For a similar approach to END for ending a program on the Spectrum try redirecting the program flow to line 9999 and include a STOP statement on that line. CONTINUE will not work after the STOP in line 9999.
See also STOP, CONT, CONTINUE.
ERROR
ERROR n (Lynx)
Result: Generates an error message derived from error code n.
Not on the Spectrum. Altering the system variable ERR_NR (address 23610) will have a similar effect, bearing in mind the error codes on the Lynx will relate to different errors to those on the Spectrum.
FLASH
FLASH n (ZX Spectrum)
Result: If n is set to 1 permanent flash effect is turned on. If n is set to zero then permanent flash effect is turned off.
keywordFLASH n (ZX Spectrum)
Result: If n is set to 1 temporary flash effect is turned on. If n is set to zero then temporary flash effect is turned off.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements. When FLASH is applied to the keyword LPRINT there will be no effect, obviously.
Not on the Lynx.
GOSUB or GO SUB
GOSUB LABEL (Lynx)
GOSUB n (Lynx)
GO SUB n (ZX Spectrum)
Result: Stack current line number and branch (GO TO) line n.
GOSUB LABELlabel_name (Lynx)
Result: Stack current line number and branch to subroutine label_name defined by LABEL statement.
Same result all round with the exception of the spelling, GO SUB with a space for the Spectrum and without (GOSUB) for the Lynx.
The ZX Spectrum manual is inconsistent with the spelling of GO SUB, using both GO SUB and GOSUB!
GOSUB LABEL can be simulated on the Spectrum by using a named variable i.e.
LET menu=9000
GO SUB menu
GOTO or GO TO
GOTO LABEL (Lynx)
GOTO n (Lynx)
GO TO n (ZX Spectrum)
Result: Branch or GO TO line n.
GOTO LABELlabel_name (Lynx)
Result: Branch to line containing label_name defined by LABEL statement.
Again, like above the Same result all round with the exception of the spelling, GO TO with a space for the Spectrum and without (GOTO) for the Lynx.
GOTO LABEL can be simulated on the Spectrum by using a named variable i.e.
LET start=9000
GOTO start
INK
INK n (Lynx & ZX Spectrum)
Result (Lynx): Sets foreground colour to n, anything displayed will be in that ink colour. If CLS is performed then the whole foreground colour will be changed.
Result (ZX Spectrum): Sets permanent foreground colour. When n=0 to 7 a colour is selected. When n=8 transparency is selected. When n=9 contrast is selected.
If CLS if performed then the INK colour will be set to n for the whole screen.
keyword INK n; (ZX Spectrum only)
Result: Sets temporary foreground colour. When n=0 to 7 a colour is selected. When n=8 transparency is selected. When n=9 contrast is selected.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements. When INK is applied to the keyword LPRINT there will be no effect on characters printed on the ZX Printer.
The colour codes 0 to 7 on the Lynx have the same meaning as those on the Spectrum.
INPUT
INPUT v1[,v2,v3...] (Lynx, and ZX Spectrum)
INPUT LINE α$ (ZX Spectrum only)
Result: Computer waits for input of an expression then passes the value of this to the variable v.
The ZX Spectrum allows PRINT items to be used such as INK and PAPER.
INPUT LINE α$ on the Spectrum strips the quotes on the input line and waits for a string to be input.
On the Lynx, data may be input on any area of the screen.
INVERSE
INVERSE n
Result: Turns permanent inverse video effect on when n=1 or off when n=0.
keywordINVERSE n
Result: Turns temporary inverse video effect on when n=1 or off when n=0.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements.
The INVERSE statement is not available on the Lynx although inverse characters can be made by using control code VDU 18 or CHR$ (18).
LET
LET v=e (Lynx & ZX Spectrum)
LET v1=e,v2=e,...,vk=e (Lynx)
Result: Assign the value e to the variable v.
Although LET is not optional on the Lynx it may be ommited when typing in a program line, the interpreter will add LET once RETURN is pressed and the program line is checked for syntax errors.
Also on the Lynx, multiple variables may be defined in one LET statement where each variable and expression must be seperated by commas.
See also: DIM.
LPRINT
LPRINT ... (Lynx and ZX Spectrum)
Result: Send a line of characters to the ZX Printer (ZX Spectrum only) or printer compatible with LPRINT.
Similar results on ZX Spectrum and Lynx.
On the Spectrum LPRINT generally works with the ZX Printer but can sometimes be used with other printer interfaces.
MOVE
MOVE x,y (Lynx)
Result: Repositions graphics cursor to location x,y.
Not on the Spectrum.
One the Spectrum the graphics cursor can be moved using:
POKE 23677,x
POKE 23678,y
where x and y are the coordinates to move the graphics cursor.
See also CIRCLE, DRAW, PLOT.
OPEN #
OPEN #m;f1[;n]¦[;n;f2] (ZX Spectrum)
Result: Open a stream m attached to channel f1 with device number n. Microdrives require a filename f2 (ZX Spectrum)
On the Spectrum the hash symbol after OPEN is not a single character but part of the OPEN # keyword.
Not on the Lynx. No similar command appears to exist for the Lynx.
OUT
OUT m,n (Lynx & ZX Spectrum)
Result: Outputs byte n to port m.
Note: Executes the Z80A instruction OUT (c),a.
As the Lynx and the ZX Spectrum use the same microprocessor (Z80A) the OUT statement will perform a similar task on both computers. Results will differ however, depending on the hardware connected to the output ports. Also, on the Lynx, address lines A8 to A15 contain the value of the B register.
See also: IN, INP.
OVER
OVER n
Result: If n=0 then permanent overprinting is turned off. If n=1 permanent overprinting is tunred on.
keyword OVER n
Result: If n=0 then temporary overprinting is turned off. If n=1 temporary overprinting is tunred on.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements. No effect when applied to LPRINT.
If n=1 OVER essentially performs an eXclusive OR with the old and new pixels. If both pixels are off (0) they will stay off (0). If the old pixel if off (0) and the new one is on (1) the displayed pixel will be on (1). If both old and new pixels are on (1) the diplayed pixel will be (0).
The Spectrum's version of OVERprinting is not available on the Lynx. The Lynx can however overprint in a similar way with the statement VDU.
VDU 20 Turns on overprinting.
VDU 21 Turns off overprinting.
Unlike the Spectrum's 'exclusive-OR' OVER statement the Lynx's VDU 20 performs an 'additive' overprint with the pixels of new characters added to the one's already there.
CHR$ (20) and CHR$ (21) may also be used instead of VDU 20 and VDU 21.
See also: CHR$, VDU.
PAPER
PAPER n (Lynx & ZX Spectrum)
Result (Lynx): Sets background colour to n, anything displayed will be in that paper colour. If CLS is performed then the whole background colour will be changed.
Result (ZX Spectrum): Sets permanent background colour. When n=0 to 7 a colour is selected. When n=8 transparency is selected. When n=9 contrast is selected.
keyword PAPER n; (ZX Spectrum only)
Result: Sets temporary background colour. When n=0 to 7 a colour is selected. When n=8 transparency is selected. When n=9 contrast is selected.
keyword may be one of PRINT, LPRINT, INPUT, PLOT, DRAW or CIRCLE statements. When PAPER is applied to the keyword LPRINT there will be no effect on characters printed on the ZX Printer.
The colour codes 0 to 7 on the Lynx have the same meaning as those on the Spectrum.
See also: INK.
PAUSE
PAUSE m (Lynx & ZX Spectrum)
Result (Lynx): Stop program execution for m*1/1000seconds.
Result (ZX Spectrum): Stop program execution for m*1/50seconds or until a key is pressed.
On the Spectrum PAUSE is interupted when a key is pressed. Also, PAUSE 0 is not timed but lasts until a key is pressed.
To convert the Lynx PAUSE to the Spectrum PAUSE divide m by 20. For Spectrum to Lynx conversion multiply m by 20.
PLOT
(Lynx)
PLOTmode,x,y (Lynx)
Result: Performs a graphic operations depending on the value of mode.
mode 0 is the same as a MOVE x,y statement
mode 1 performs MOVE relative to current hi-res cursor position
mode 2 is the same as a DRAW x,y statement
mode 3 as DRAW x,y but draws a line relative to the current hi-res cursor position
mode 4 places a single pixel at coordinates x,y (same as DOT x,y)
modes 3 and 4 are essentially the same as the ZX Spectrum's DRAW and PLOT respectively.
See also: DOT, DRAW, PLOT (ZX Spectrum), MOVE.
PLOT
(ZX Spectrum)
PLOT [c;]m,n (ZX Spectrum)
Result: Sets pixel ink at position m,n subject to c (INK/PAPER/OVER/INVERSE) on the ZX Spectrum.
On the Lynx DOT has the same purpose.
See also: CIRCLE, DOT, DRAW, PLOT (Lynx).
POKE
POKE m,n (Lynx and ZX Spectrum)
Result: Load byte n into memory address m.
Same usage on both micros.
See also: DPEEK, DPOKE, PEEK.
PRINT
PRINT ... (Lynx and ZX Spectrum)
Result: Send a series of items to the display subject to control characters (and AT/TAB/INK/PAPER/INVERSE/FLASH/OVER on the ZX Spectrum).
Similar on both micros with exceptions.
PRINT@
(Lynx)
See AT
PROC
PROCprocedure_name [(α1[,...,αk])] (Lynx)
Result: Calls procedure_name defined by DEF PROC passing any optional variables to that procedure.
Not on the Spectrum, use GO SUB with named variables instead.
See also: DEF PROC, END PROC, GO SUB.
RANDOMIZE
(ZX Spectrum)
RANDOM
(Lynx)
RANDOMIZE [n] (ZX Spectrum)
Result: Sets system variable SEED to n which will be the basis for pseudo-random numbers (RND). n can be any number between 0 and 65535. When n=0 or if no number is given, then the pseudo-random number sequence is based upon the time elapsed since the Spectrum was powered on.
RANDOM (Lynx)
Result: Resets intial value of random number generator.
The Lynx's RANDOM statement has no operands so when converting programs for the ZX Spectrum use RANDOMIZE or RANDOMIZE 0.
ZX Spectrum keyboard shows shortened RAND and not RANDOMIZE.
See also: RAND, RND.
READ
READ e1,e2,e3, ... (Lynx & ZX Spectrum)
Result: Read numeric or string information from DATA statement and pass to a variable or variables e1,e2,e3, ...
Similar on both micros with exceptions.
Lynx string expressions within DATA statements must not be contained within quotes.
See also: DATA, RESTORE.
REM
REM ... (Lynx and ZX Spectrum)
Result: None, displays comment in program listing.
Same result all round.
RESTORE
RESTORE [n] (Lynx and ZX Spectrum)
Result: Restores DATA pointer to start of program or line number n, if specified.
Same for both micros.
See also DATA, READ.
RETURN
RETURN
Result: Take line number off GO SUB stack and GO TO the line after that line number.
Same result all round.
ROUND
ROUND ON¦OFF (Lynx)
Result: Rounds the result of calculation to 6 digits when ON. When OFF 8 digits are displayed.
ROUND defaults to ON.
Not on the Spectrum.
The number of digits displayed includes the integer part as well as the fractional part of the calculation i.e. 3.14159 or 10.5423
To achieve the same result as ROUND ON use the following Spectrum code:
LET scale=INT (EXP((6-INT (LN n/LN 10)-1)*LN 10))
LET display=INT (n*scale)/scale
PRINT display
Where n is the 8 (or more) digit number to round to 6 digits.
Note: The above code should only be used to display a final calculation otherwise rounding errors could creep in.
See also INT, TRAIL.
SOUND
SOUNDaddress,delay_between_outputs (Lynx)
Result: Converts values, starting at specified address to sounds.
delay_between_outputs may be from 0 to 65535
end marker has a value of zero.
Not on the Spectrum, but a short machine code subroutine could be used to play back sound from memory.
See also BEEP
SWAP
SWAP v1,v2 (Lynx)
Result: The contents of variables v1 and v2 are swapped.
Not on the Spectrum.
SWAP only works with numeric variables.
The most efficient way to swap two numeric variables on the Spectrum is to use the following code:
LET a=a+b
LET b=a-b
LET a=a-b
Where a and b are the two numeric variables to be swapped.
See also: LET.
TRAIL
TRAIL ON¦OFF (Lynx)
Result: Add trailing zeros to displayed calculation when ON (either up to 6 or 8 digits depending on whether the ROUND statement is ON or OFF). When OFF trailing zeros are disabled.
TRAIL defaults to OFF.
Not on the Spectrum.
To achieve the same result as TRAIL ON for 6 digits use the following Spectrum code:
LET s$=STR$ display
IF display=INT display THEN LET s$=s$+"000000" ( TO 7-LEN s$)
PRINT s$
Where the variable display is the number to add trailing zeros to.
For 8 digits change the second line of code to:
IF display=INT display THEN LET s$=s$+"00000000" ( TO 9-LEN s$)
See also INT, ROUND.
STOP
STOP
Result: Stops program execution. (Lynx & ZX Spectrum).
CONT (Lynx) and CONTINUE (ZX Spectrum) will resume program execution.
Same result all round.
For the Lynx see also END.
TAB
TAB x (Lynx & ZX Spectrum)
Result: Changes PRINT (Lynx and ZX Spectrum), LPRINT (ZX Spectrum) or INPUT (ZX Spectrum) position to column x.
The Lynx has 40 character positions compared to the Spectrum's 32, other than that TAB will work the same for both micros.
The Lynx manual lists TAB as PRINT TAB, but it still works the same way as the Spectrum in that you can place text before or after the TAB statement seperated by semi-colons, for this reason it is listed here as TAB.
INPUT TAB x only works on ZX Spectrum.
VDU
VDU m1[,m2,...,mk] (Lynx)
Result: Display ASCII character on screen or activate control codes.
Works just like:
PRINT CHR$ (m1)[;CHR$ (m2);...CHR$ (mk)]
What follows is a list of VDU codes and the functions associated with them and a translation to ZX Spectrum CHR$ codes where possible.
VDU 0 - not used
VDU 1 - INK control, use CHR$ 16+CHR$ colour code
VDU 2 - PAPER control, use CHR$ 17+CHR$ colour code
VDU 3 - not used
VDU 4 - clear screen and home cursor - no ZX Spectrum control available, use CLS instead
VDU 5 - moves cursor up one pixel line* - no ZX Spectrum control code available, subtract one from the value stored in memory location 23678 to move the graphics cursor up
VDU 6 - moves cursor down one pixel line* - no ZX Spectrum control code available, add one to the value stored in memory location 23678 to move the graphics cursor down
VDU 7 - beep - no control available, useBEEP .25,12 instead.
VDU 8 - backspace and erase character - use control code CHR$ 8+CHR$ 32 together
VDU 9 - tab cursor to next field - use control code CHR$ 23+CHR$ m where m is the TAB column to move the cursor to.
VDU 10 - line feed (move cursor down ten pixels) - use CHR$ 21+CHR$ 1+s$(32)+CHR$ 21+CHR$0 where s$(32) is a string of 32 spaces
VDU 11 - not used
VDU 12 - moves cursor one character block to the right - use CHR$ 21+CHR$ 32+CHR$ 21+CHR$0
VDU 13 - carriage return (next line) and clear to end of line - use CHR$ 23+CHR$ 32+CHR$ 13
VDU 14 - cursor off - No ZX Spectrum equivalent
VDU 15 - cursor on - No ZX Spectrum equivalent
VDU 16 - move cursor to top of screen -use CHR$ 22+CHR$ 0+CHR$ 0
VDU 17 - not used
VDU 18 - inverse Video (swap INK and PAPER) - use CHR$ 20+CHR$ 1 for INVERSE on and CHR$ 20+CHR$ 0 for INVERSE off
VDU 19 - if cursor is not at the begining then perform carriage return - use PRINT CHR$ 13 AND (32-PEEK 23688);
VDU 20 - overwrite off - use CHR$ 21+CHR$ 0
VDU 21 - overwrite on - use CHR$ 21+CHR$ 1
VDU 22 - backspace - use control code CHR$ 8
VDU 23 - homes cursor inside window - no ZX Spectrum equivalent
VDU 24 - double height characters on - no ZX Spectrum equivalent
VDU 25 - double height characters off - no ZX Spectrum equivalent
VDU 26 - not used
VDU 27 - not used
VDU 28 - move cursor 3 pixels up (superscript)* - no ZX Spectrum equivalent
VDU 29 - move cursor 3 pixels down (subscript)* - no ZX Spectrum equivalent
VDU 30 - clear to end of line - use CHR$ 23+CHR$ 32
*The Lynx has the ability to place text on screen with pixel resolution, the Spectrum does not. Text on the Spectrum is confined to character block squares only unless additional print routines are introduced.
Not on the Spectrum.
Use PRINT CHR$ where appropriate.
See also: CHR$, PRINT.
WINDOW
WINDOW x1,x2,y1,y2 (Lynx)
Result: Create a text window from column x1 to column x2+1 and from row y1 to row y2+1
Window dimensions may be up to 126 column and 248 rows (dimensions are measured in pixels not character blocks).
Full screen setting for WINDOW is:
WINDOW 3,123,5,245
Not on the Spectrum.
BASIC extensions such as YS MEGABASIC have the ability to create and manipulate windows.
Compound Statements
Keyword
Meaning
Comments
FOR...NEXT loop
(FOR, TO, STEP, NEXT)
FOR α=x TO y STEP z
[section of program to be repeated goes here]
NEXT α
Result: Sets up and executes the loop α from x to y with a step of z.
[Note] Step of +1 assumed if STEP omitted).
Same result all round.
Although the NEXT statement is not compounded within the FOR statement as TO and STEP are, it is included here for completeness.
IF..THEN
(Lynx & ZX Spectrum)
IF..THEN..ELSE
(Lynx)
IF x THEN s (Lynx & ZX Spectrum)
Result: If x is true (non-zero) then s will be executed.
IF x THEN s1
ELSE s2 (Lynx)
Result: If x is true (non-zero) then s1 will be executed, otherwise s2 will be executed (Note: ELSE is on the next line after the IF..THEN statement, not on the same line like some other dialects of BASIC).
ELSE can be simulated on the ZX Spectrum by skipping the line immediately after the IF..THEN if the condition is true.
IFconditionTHENstatement : GO TO next_statement
else_statement
next_statement
DEFPROC...ENDPROC
(Lynx)
DEFPROCprocedure_name [(α1[,...,αk])]
[multi-line expressions go here]
ENDPROC (Lynx)
Result: Defines a procedure. Optional variables α1 to αkmay be passed to the procedure. procedure_name must not contain brackets since brackets must enclose the variables to be called.
Not on the ZX Spectrum, GO SUB should be used in lieu of PROC.
Simple named procedures can be structured on the Spectrum by defining a named variable as the line number of the 'procedure'. Care must be taken if renumbering a program which contains variables storing line numbers.
See also GO SUB, PROC.
REPEAT...UNTIL
REPEAT
statements
UNTILcondition (Lynx)
Result: Sets up and executes a REPEAT loop and performs statements. When condition is met UNTIL closes the loop.
Not on the ZX Spectrum but a REPEAT loop to wait for a keypress can be achieved with the following code.
LET exit=1
FOR r=0 TO 0 STEP 0
IF INKEY$<>"" THEN LET r=exit
NEXT r
Explanation:
The exit variable is set to '1'. This is just a convenient name to make the program easier to follow.
The FOR loop is a dummy loop which will be our REPEAT.
Next comes the line which checks for a keypress. If true r, the REPEAT loop variable, will be set to exit or 1, and the loop will be exited at NEXT r
NEXT r completes the loop, this is the equivalent of UNTIL.
DEFPROC...ENDPROC
(Lynx)
DEFPROCprocedure_name [(α1[,...,αk])]
[multi-line expressions go here]
ENDPROC (Lynx)
Result: Defines a procedure. Optional variables α1 to αkmay be passed to the procedure. procedure_name must not contain brackets since brackets must enclose the variables to be called.
Not on the ZX Spectrum, GO SUB should be used in lieu of PROC.
Simple named procedures can be structured on the Spectrum by defining a named variable as the line number of the 'procedure'. Care must be taken if renumbering a program which contains variables storing line numbers.
See also GO SUB, PROC.
WHILE...WEND
WHILEcondition
statements
WEND (Lynx)
Result: Sets up and executes a WHILE loop and, as long as condition is me, performs statements.
Not on the ZX Spectrum.
The way that WHILE...WEND loops differ from REPEAT...UNTIL is that WHILE...WEND loops check that the condtion to perform a loop comes before the loop is executed, REPEAT...UNTIL loops will always perform at least one loop irrespective of the condition required to exit the loop.
The easiest way to simulate a WHILE...WEND loop on the Spectrum is to use something like the following at the start of a loop.
IF NOTconditionTHEN GO TOexit
Where condition is the condition to be met to continue the loop and exit is the line number to GO TO to exit the loop.
Functions
Keyword
Meaning
Comments
ABS
ABS x (ZX Spectrum)
ABS (x) (Lynx)
Returns: Absolute magnitude of x, i.e. distance on number line from zero, -1=1 -2=2
Same result all round.
ALPHA
ALPHA (no operands) (Lynx)
Returns: Address of the start of the character set.
Not on the Spectrum but
USR "a"
works in a similar way by returning the address of the start of the user defined graphics area.
See also USR.
ACS
(ZX Spectrum)
ARCCOS
(Lynx)
ACS x (ZX Spectrum)
ARCCOS x (Lynx)
Returns: Arccosine (inverse cosine) of x in radians.
Same on both micros.
ASC
See CODE (ZX Spectrum function)
ASN
(ZX Spectrum)
ARCSIN
(Lynx)
ASN x (ZX Spectrum)
ARCSIN (x) (Lynx)
Returns: Arcsine (inverse sine) of x in radians.
Same on both micros.
ATN
(ZX Spectrum)
ARCTAN
(Lynx)
ATN x (ZX Spectrum)
ATN (x) (Lynx)
Returns: Arctangent (inverse tangent) of x in radians.
Same result all round.
ATTR
ATTR (x,y)
Returns: numeric value between 0 and 255 of the attribute at position x,y.
Not on the Lynx. See also POINT, SCREEN$, SCRN.
CHR$
CHR$ x (ZX Spectrum)
CHR$ (x) (Lynx)
Returns: Single character or control code, from position x in the character set.
Although the CHR$ function performs the same task on both the Spectrum and Lynx, the end result may be different. Both micros use a character set based on ASCII.
CODE (ZX Spectrum function)
ASC (Lynx)
CODE α$ (ZX Spectrum)
ASC (α$) (Lynx)
Returns: Numeric value (between 0 and 255) representing the position in the character set of α$. This is the inverse of the CHR$ function.
Not to be confused with the Lynx's CODE statement.
Although the CODE / ASC function performs the same task on both computers, just like CHR$ above, the end result may be different.
ASC is not described in the Lynx manual, but works on an emulated Lynx.
See also: CHR$
COS
COS x (ZX Spectrum)
COS (x) (Lynx)
Returns: Cosine of x in radians.
Same result all round.
DPEEK
DPEEK (m) (Lynx)
Returns: numeric value (0 to 65535) stored at memory locations m and m+1. This function performs a double PEEK or to put it another way it converts a base256 number to a decimal (base10) number.
DPEEK can be acheived on the Spectrum with the following code:
PEEK m+256*PEEK (m+1)
EXP
EXP x (ZX Spectrum)
EXP (x) (Lynx)
Returns: Numeric value for the function ex where e=2.7182818...
Same result all round.
FACT
FACT (x) (Lynx)
Returns: x! (factorial of x).
Not on the Spectrum but a simple iterative routine can be used to find x!.
FN
FN α(α1, αk) (ZX Spectrum)
Result: Calls a function. α and α1 to αk can be a single letter only or a single letter followed by $ for a string argument.
A definable function on the ZX Spectrum may be numeric or string.
Definable functions are not present on the Lynx computer.
See also DEF FN.
GETN
GETN (no operands) (Lynx)
Returns: ASCII code or character after waiting for a key press.
Not on the Spectrum.
This function can be simulated with a short subroutine:
1000 REM **GET KEY PRESS**
1010 PAUSE 0
1020 LET k$=INKEY$
1030 IF k$="" THEN GO TO 1010
1040 LET GETN=CODE k$
1050 RETURN
The subroutine is called with a GO SUB to line 1000 and uses the string variable k$ to temporarily store the ASCII character relating to the key which has just been pressed. The function CODE is then applied to k$ to obtain the character's ASCII code, this is then stored is the variable GETN. k$ contains the character relating to the key which was pressed.
See also GET$, INKEY$, KEYN, KEY$.
GET$
GET$ (Lynx)
Returns: ASCII character after waiting for a key press (Lynx).
Not on the Spectrum.
This function can be simulated with a short subroutine:
1000 REM **GET KEY PRESS 2**
1010 PAUSE 0
1020 LET k$=INKEY$
1030 IF k$="" THEN GO TO 1010
1040 RETURN
The subroutine is called with a GO SUB to line 1000 and uses the string variable k$ to temporarily store the ASCII character relating to the key which has just been pressed. This is almost the same routine that is used to simulate GETN and if required it would be better to use that one as it will simulate GETN and GET$.
See also GETN, INKEY$, KEYN, KEY$.
GRAPHIC
GRAPHIC (no operands) (Lynx)
Returns: Address of the start of the duplicate character set, user defined graphics can be stored here.
Not on the Spectrum but
USR "a"
works in a similar way by returning the address of the start of the user defined graphics area.
See also USR.
KEYN
KEYN (Lynx)
Returns: ASCII code from a single keypress. Zero if no key pressed.
Not on the Spectrum, use the following code instead:
LET KEYN=CODE INKEY$
See also: GET$, GETN, INKEY$, KEY$.
INKEY$
(ZX Spectrum)
KEY$
(Lynx)
KEY$ (Lynx)
INKEY$ (ZX Spectrum)
Both KEY$ and INKEY$ requires no operands.
Returns: Single character from a keypress.
Typical usage would be
PRINT INKEY$ (ZX Spectrum)
PRINT KEY$  (Lynx)
LET A$=INKEY$  (ZX Spectrum)
or
10 IF INKEY$="" THEN GO TO 10 (ZX Spectrum)
Difference in spelling but the same result all round.
IMPORTANT NOTE
The keyword KEY$ does not appear in the Lynx user manual and has only been tested on the Jynx emulator.
See also: GET$, GETN, KEYN.
IN
(ZX Spectrum)
INP
(Lynx)
IN m (ZX Spectrum)
INP(m) (Lynx)
Returns: numeric value between 0 and 255 for the port m.
IN and INP both perform the same task as the ZX Spectrum and Lynx use the Z80A microprocessor, however differences in circuit board design mean ports may return different or unexpected values.
See also: OUT.
INT
INT x (ZX Spectrum)
INT(x) (Lynx)
Returns: x rounded down to the greatest integer (floor).
Mostly the same result on each micro with the exception that occurs on the ZX Spectrum when INT -65536 is performed (the wrong result is given as -1).
KEY$
See INKEY$
LEFT$
LEFT$(α$,m) (Lynx)
Returns: First m characters of α$.
On the Spectrum LEFT$ can be emulated with the TO string slicing facility:
β$=α$( TO m)
See also MID$, RIGHT$, TO.
LEN
LEN(α$) (Lynx)
LEN α$ (ZX Spectrum)
Returns: numeric value for the length of α$.
Same result all round.
LN
LN(x) (Lynx)
LN x (ZX Spectrum)
Returns: numeric value for the natural logarithm of x.
Similar result all round.
See also ANTILOG, EXP, LOG, ↑, **.
LCTN
LCTN (n) (Lynx)
Returns: The address of where machine code is stored within a BASIC program at line n.
Not on the Spectrum, the closest analogy would be storing machine code in REM statements.
See also: CALL, CODE (Lynx), HL, USR.
LOG
LOG(x) (Lynx)
Returns: numeric value for the common logarithm to base 10 of x.
Not on the Spectrum.
A function can be defined to perform the same task:
DEF FN l(x)=LN x/LN 10
See also EXP, LN, ↑, **.
MID$
MID$(α$,m,n) (Lynx)
Returns: n characters of α$, starting at position m.
On the Spectrum MID$ can be emulated with the TO string slicing facility:
β$=α$(m TO m+n-1)
See also LEFT$, RIGHT$, TO.
PEEK
PEEK(m) (Lynx)
PEEK m (ZX Spectrum)
Returns: numeric value (0 to 255) stored at memory location m.
PEEK on the Spectrum and the Lynx have the same purpose although both will yield different results depending on the context of the program within which it is used.
See also POKE.
POINT
POINT (x,y) (ZX Spectrum)
Returns: 1 if pixel is on or 0 if it is off, for the pixel location x,y.
There does not appear to be an equivalent function on the Lynx.
POS
POS (Lynx)
Result: Returns current horizontal cursor (0 to 126).
POS returns the first pixel of the current character block. To find the character position use:
INT ((POS+1)/3)-1
To find the current column position on the ZX Spetrum use:
33-PEEK 23688
For the current ZX Printer column position use:
PEEK 23680-(PEEK 23680)<32
RIGHT$
RIGHT$(α$,m) (Lynx)
Result: Returns last m characters of α$.
On the Spectrum RIGHT$ can be emulated with the TO string slicing facility:
β$=α$(LEN α$-m+1 TO )
See also LEFT$, MID$, TO.
RND
RND (Lynx & ZX Spectrum)
Result: A pseudo-random number between 0 and 1 is generated.
Similar operation on both micros (for obvious reasons both micros should always return different values!).
See also RAND, RANDOMIZE.
SCREEN$
SCREEN$ (x,y) (ZX Spectrum)
Returns: character displayed at location x,y.
Not on the Lynx.
See also POINT.
SGN
SGN(x) (Lynx)
SGN x (ZX Spectrum)
Returns: signum (or sign) of x, for instance -1 if x<0, 0 if x=0 or 1 if x>1.
On the Lynx brackets are obligatory.
SIN
SIN(x) (Lynx)
SIN x (ZX Spectrum)
Returns: Sine of x in radians.
Same result all round.
SQR
SQR(x) (Lynx)
SQR x (ZX Spectrum)
Returns: square root of x.
Same result all round.
STR$
STR$ x (ZX Spectrum)
Result: string comprising of the numeric value of x.
Not on the Lynx.
The following code will simulate STR$ but will only return positive integers.
LET N=number to be converted to a string
LET S$ = ""
IF N= 0 THEN LET S$="0"
WHILE N>0
LET D=N MOD 10
LET S$=CHR$(D+48)+S$
LET N=INT(N/10)
WEND
PRINT "Result: "; S$
See also: VAL
TAN
TAN(x) (Lynx)
TAN x (ZX Spectrum)
Returns: Tangent of x in radians.
Same result all round.
UPC$
UPC$ (α$) (Lynx)
Returns α$ with all lower case letters converted to uppercase.
Not on the Spectrum. A short subroutine can simulate UPC$:
1010 REM convert a$ to uppercase
1020 FOR f=1 TO LEN a$
1030 LET a$(f)=CHR$CODE a$(f)-(32 AND (CODE a$(f)>96 AND CODE a$(f)<123)))
1040 NEXT f
1050 REM a$ returns uppercase
USR
(Numeric argument)
USR m (ZX Spectrum)
Returns: contents of the bc register pair after calling machine code at memory location m.
The ZX Spectrum will return the value of the bc register pair (Z80).
The Lynx does not have a USR function but instead uses the CALL command to run a machine code subroutine. The pseudo-variable HL returns the contents on the hl register pair.
To return the contents of the bc register pair like the Spectrum use the following Z80 code:
push bc
pop hl
The contents of bc will now be stored in the pseudo-variable HL
See also CALL, HL.
USR
(String argument)
USR α$ (ZX Spectrum)
Returns: location in memory of user defined graphic α$.
The function USR (with string argument) is completely different to USR (numeric argument) above and is used to find the location of a particular user-defined graphic.
The Lynx has a different way of defining UDGs. Lynx UDGs are formed from characters of 6x10 pixels and are pointed to in memory using the GRAPHIC function.
See also GRAPHIC.
VAL
VAL(α$) (Lynx)
VAL α$ (ZX Spectrum)
Returns: numeric value evaluated from the string α$.
The Lynx will only evaluate numbers, anything else will return a zero and only the first value before an expression will be evaluated i.e.VAL("10*20") will evaluate as 10.
The ZX Spectrum will evaluate numbers, mathematical operators, logical operators and variables.
VAL$
VAL$ α$
Returns: string evaluated from the string α$.
There does not appear to be a simple way to simulate this function in Lynx Basic.
For an explantion of the VAL$ function follow this link.
VPOS
VPOS (no operands) (Lynx)
Returns: Vertical position of text cursor from 0 to 240.
VPOS returns the first pixel position of the character block. To get the vertical character position use:
INT (VPOS/10)
VPOS is not available on the Spectrum but
24-PEEK 23689
will do a similar thing.
Memory location 23689 is the location for the second part of the system variable S POSN.
See also POS.
Constants
Keyword
Meaning
Comments
BLACK
BLACK (Lynx)
Returns: The numerical value of 0.
Not on the Spectrum. Can be replaced in a program simply with :
0
or by defining a variable in lieu of a BLACK constant.
LET BLACK=0
See also BLUE, RED, MAGENTA, GREEN, CYAN, YELLOW, WHITE.
BLUE
BLUE (Lynx)
Returns: The numerical value of 1.
Not on the Spectrum. Can be replaced in a program simply with :
1
or by defining a variable in lieu of a BLUE constant.
LET BLUE=1
See also BLACK, RED, MAGENTA, GREEN, CYAN, YELLOW, WHITE.
CYAN
CYAN (Lynx)
Returns: The numerical value of 5.
Not on the Spectrum. Can be replaced in a program simply with :
5
or by defining a variable in lieu of a CYAN constant.
LET CYAN=5
See also BLACK, BLUE, RED, MAGENTA, GREEN, YELLOW, WHITE.
FALSE
FALSE (Lynx)
Returns: The numerical equivalent of zero.
Not on the Spectrum. Can be replaced in a program simply with :
0 (zero!)
or by defining a variable in lieu of a FALSE constant.
LET FALSE=0
See also TRUE.
GREEN
GREEN (Lynx)
Returns: The numerical value of 4.
Not on the Spectrum. Can be replaced in a program simply with :
4
or by defining a variable in lieu of a GREEN constant.
LET GREEN=4
See also BLACK, BLUE, RED, MAGENTA, CYAN, YELLOW, WHITE.
INF
INF (Lynx)
Returns: Not quite infinity, but the largest numeric value possible on the Lynx.
The largest possible numeric value the Lynx can hold is 10^60 and it is this number that is taken to be infinity.
The largest possible numeric value the Spectrum can handle is 10^38.
10^38 can act like infinity as if we add 1 to it it will stay at 10^38 just like infinity. The same goes for subraction but division will work as normal and multiplication and exponential will cause a 'Number to big' error.
MAGENTA
MAGENTA (Lynx)
Returns: The numerical value of 3.
Not on the Spectrum. Can be replaced in a program simply with :
3
or by defining a variable in lieu of a MAGENTA constant.
LET MAGENTA=3
See also BLACK, BLUE, RED, GREEN, CYAN, YELLOW, WHITE.
PI
PI
PI requires no operands.
Returns: 3.1415927 (ZX Spectrum & Lynx)
(π) Ratio of circumference of a circle to its diameter
Typical usage might be:
LET R=C/(2*PI)
PI (π) is stored on the Spectrum as 10 digits but will only display 8 digits.
RED
RED (Lynx)
Returns: The numerical value of 2.
Not on the Spectrum. Can be replaced in a program simply with :
2
or by defining a variable in lieu of a RED constant.
LET RED=2
See also BLACK, BLUE, MAGENTA, GREEN, CYAN, YELLOW, WHITE.
TRUE
TRUE (Lynx)
Returns: The numerical equivalent of one (1).
Not on the Spectrum. Can be replaced in a program simply with :
1 (See note)
or by defining a variable in lieu of a TRUE constant.
LET TRUE=1
See also FALSE.
YELLOW
YELLOW (Lynx)
Returns: The numerical value of 6.
Not on the Spectrum. Can be replaced in a program simply with :
6
or by defining a variable in lieu of a YELLOW constant.
LET YELLOW=6
See also BLACK, BLUE, RED, MAGENTA, GREEN, CYAN, WHITE.
WHITE
WHITE (Lynx)
Returns: The numerical value of 7.
Not on the Spectrum. Can be replaced in a program simply with :
7
or by defining a variable in lieu of a WHITE constant.
LET WHITE=7
See also BLACK, BLUE, RED, MAGENTA, GREEN, CYAN, YELLOW.
Pseudo-Variables
Keyword
Meaning
Comments
HIMEM
HIMEM (Lynx)
Returns: The address of the first available address after the stack. HIMEM is a read-only variable and cannot be changed by the user.
As the Spectrum stores its stack after the BASIC program area rather than before as the Lynx does, the closest analogy to HIMEM would be the system variable 'RAMTOP' which is stored in two bytes at locations 23730 and 23731.
HL
HL (Lynx)
Result: The contents of the Z80 HL register pair are stored in the pseudo-variable HL. HL is a read-only variable and cannot be changed by the user.
The Spectrum returns the contents of the BC register pair after returning from a USR call.
LET BC=USRaddress
The above code will perform a similar function. HL may be passed to BC before returning with the following z80 instructions.
push hl
pop bc
See also: CALL, CODE (Lynx), LCTN, USR.
Operators
Keyword
Meaning
Comments
-
Unary Minus/Negation
-x
Result: negates x.
Same result all round.
-
Binary Minus/Subtraction
x-y
Result: a numeric value resulting from y being subtracted from x.
Same result all round.
+
Addition
x+y
Result: a numeric value resulting from y being added to x.
Same result all round.
+
String concatenation
α$+β$
Result: concatenates (joins together) string α with string β to form a new string.
Same result all round.
/
Division
x/y
Result: a numeric value resulting from x being divided by y.
Same result all round.
*
Multiplication
x*y
Result: a numeric value resulting from x being multiplied by y.
Same result all round.
↑ or **
Raise to the power of
x↑y (ZX Spectrum)
x**y (Lynx)
Result: a numeric value resulting from x being raised to the power of y (xy).
On the ZX Spectrum, if the base number (x) is negative it will produce an 'Invalid Argument' error. A function can be defined to get round this :
DEF FN e(x,y)=(SGN x*(y/2<> INT (y/2)+(y/2=INT (y/2)))*ABS x↑y
<
Less than
x<y
Where x and y can be either numeric or strings but cannot be mixed (ZX Spectrum).
Where x and y are both numeric (Lynx).
Result: 1 if x<y otherwise 0.
Same result on both micros except that only the Spectrum can handle strings with the < operator.
>
Greater than
x>y
Where x and y can be either numeric or strings but cannot be mixed (ZX Spectrum).
Where x and y are both numeric (Lynx).
Result: 1 if x>y otherwise 0.
Same result on both micros except that only the Spectrum can handle strings with the > operator.
<=
Less than or equal to
x<=y
Where x and y can be either numeric or strings but cannot be mixed (ZX Spectrum).
Where x and y are both numeric (Lynx).
Result: 1 if x≤y otherwise 0.
Same result on both micros except that only the Spectrum can handle strings with the <= operator.
>=
Greater than or equal to
x>=y
Where x and y can be either numeric or strings but cannot be mixed (ZX Spectrum).
Where x and y are both numeric (Lynx).
Result: 1 if x≥y otherwise 0.
Same result on both micros except that only the Spectrum can handle strings with the >= operator.
=
Variable assignment
LET x=y (ZX Spectrum & Lynx)
Where x and y can be either numeric or strings but cannot be mixed.
Result: x is assigned the value y.
Same result all round.
=
Is equal to
x=y
Where x and y can be either numeric or strings but cannot be mixed.
Result: 1 if x=y otherwise 0.
Same result all round.
<>
Is not equal to
x<>y
Where x and y can be either numeric or strings but cannot be mixed.
Result: 1 if x≠y otherwise 0.
Same result on both micros except that only the Spectrum can handle strings with the <> operator.
AND
x AND y
Where x is a number or a string, and y is always numeric. (ZX Spectrum)
Where x and y are both expressions. (Lynx)
Returns (ZX Spectrum): x if y is true (non-zero) or 0 if y is false (zero).
Returns (Lynx): 1 if x and y are true, 0 if x or y are false.
AND on the Lynx works differently to the Spectrum 'AND'.
For one thing the Lynx cannot use AND with strings, and secondly the Lynx will return 1 as long as both x and y are not zero whereas the Spectrum will return x if y<>0.
BIN
BIN b (ZX Spectrum)
BIN (b¦v) (Lynx)
Returns: decimal value of a base2 (binary) 16 bit number.
Not strictly a function but a numerical notation.
The Lynx can accept a variable which stores a binary number.
A Spectrum function can be defined to accept a binary (base2) number or a variable containing a binary number:
DEF FN b(b)=VAL VAL$ """BIN""+STR$ b"
A variable may be used to store a number in binary format i.e. :
LET number=10101010
and FN b(number) will call the function which will return 170.
For a more detailed explanation of how VAL$ works follow this link.
BNAND
m BNAND n
Where m and n are both numeric. (Lynx)
Result : A 16-bit integer from the bitwise calculation of m and n. Bits in m and n are compared. If bits in both m and n are 1 then the resulting bit, after performing a bitwise AND, will be 1 otherwise it will be 0. (Lynx)
A short machine code routine could simulate BNAND on the ZX Spectrum.
BNOR
m BNOR n
Where m and n are both numeric. (Lynx)
Result : A 16-bit integer from the bitwise calculation of m and n. Bits in m and n are compared. If bits in either m or n are 1 then the resulting bit, after performing a bitwise OR, will be 1 otherwise it will be 0. (Lynx)
A short machine code routine could simulate BNOR on the ZX Spectrum.
BNXOR
m BNXOR n
Where m and n are both numeric. (Lynx)
Result : A 16-bit integer from the bitwise calculation of m and n. Bits in m and n are compared. If bits in either m or n, but not both, are 1 then the resulting bit, after performing a bitwise OR, will be 1 otherwise it will be 0. (Lynx)
A short machine code routine could simulate BNOR on the ZX Spectrum.
DIV
x DIV y (Lynx)
Result: An integer divsion of x divided by y.
Not on the Spectrum but easily reproduced with the following function:
DEF FN d(x,y)=INT(x/y)
where x is the numerator and y is the denominator.
See also FRAC, INT, MOD.
FRAC
FRAC (x) (Lynx)
Returns: Fractional part of x.
Not on the Spectrum but the following code will work just as well:
x-INT x
MOD
m MOD n (Lynx)
Returns: Modulus (remainder) of m divided by n.
The modulus can be found on the Spectrum with the function:
DEF FN M(m,n)=INT(m-(INT(m/n)*n))
See also DIV, FRAC, INT.
NOT
NOT x¦e
Where x is numeric, or an expression may be used.
Returns (Lynx & Spectrum): zero if x≠0, 1 if x=0.
Same result on both micros.
OR
x OR y
Where x and y are both numeric.
Returns (ZX Spectrum): 1 if x or y≠0, value of x if y=0.
Returns (Lynx): 1 if either x or y are not equal to zero, 0 if both x and y are zero.
Similar on both micros except that the Spectrum will return x if y=0 whereas the Lynx return 1 if x≤≥0 and y=0 regardless of the value of x.
Delimiters
Keyword
Meaning
Comments
TO
v$(x TO y)
v$(x TO)
v$(TO y)
v$( TO ) * This works but is pointless!
Returns: Slices string v from x to y, x to end of string or start of string to y. TO without any operands will return a string unsliced (see fourth example).
Not on the Lynx. For the equivalent string slicing statements see LEFT$, MID$ and RIGHT$.
;
Semi-colon
PRINT ; (Lynx and ZX Spectrum)
LPRINT ; (Lynx and ZX Spectrum only)
INPUT ; (ZX Spectrum)
INPUTmessage;v (Lynx and ZX Spectrum)
Result: separates items within a PRINT, LPRINT, or INPUT statement.
message is text within double quotes. v is a numeric or string variable.
Similar usage all round.
'
Apostrophe
PRINT ' (ZX Spectrum)
LPRINT ' (ZX Spectrum)
INPUT ' (ZX Spectrum)
Result: Moves the PRINT or LPRINT position down a line.
The Lynx does use an apostrophe as a delimiter in INPUT, LPRINT, or PRINT statements.
To 'carriage return' on the Lynx (PRINT statement only) define a string variable holding the following control codes:
CHR$(10)+CHR$(22)
Place the variable in a PRINT statement between semi-colons and this will achieve the same result as the apostrophe on the ZX Spectrum.
,
Comma
as a PRINT item
PRINT , (Lynx and ZX Spectrum)
LPRINT , (Lynx and ZX Spectrum)
INPUT , (ZX Spectrum*)
Result: Moves the PRINT position to halfway across the screen (or printer) or to the start of the next line if PRINT position is greater or equal to halfway.
*The Lynx may only use a comma within an INPUT statement to seperate operands.
ZX Spectrum INPUT comma works, just like the PRINT comma, by moving the PRINT position 15 characters along.
,
Comma
as an operand/parameter delimiter
Examples:
POKE x,y (Lynx and ZX Spectrum)
ATTR (x,y) (ZX Spectrum)
Result: Separates operands/parameters within a statement.
Mostly the same all round.
#
Hash
as a stream prefix
PRINT #m (ZX Spectrum only)
LPRINT #m (ZX Spectrum only)
OPEN #stream_number;device;device_number;filename
(ZX Spectrum with ZX Interface 1)
Result: Channel input/ouput through stream m.
The standard Lynx microcomputer does not have I/O streams and channels.
Some statements on the ZX Spectrum may require the ZX Interface 1.
#
Hash
as a decimal number prefix
# n (Lynx)
Returns: a hexadecimal (base16) number, plus the suffix 'H', from the decimal (base10) number n.
A short BASIC routine could be written to convert decimal to hexadecimal, on the Spectrum.
&
Ampersand
as a hexadecimal number prefix
&h (Lynx)
Returns: a decimal (base10) number from the hexadecimal (base16) number h.
A short BASIC routine could be written to convert hexadecimal to decimal, on the Spectrum.
:
Colon
Type: Statement delimiter
s1 : s2 : s3 ...
Result: Allows more than one statement per line number to be entered.
Same result all round.
"
Single quotation marks
α$="some text" (Lynx and ZX Spectrum)
PRINT "some text" (Lynx and ZX Spectrum)
LPRINT "some text" (Lynx and ZX Spectrum)
INPUT "some text" (Lynx and ZX Spectrum)
Result: Encloses text within a string or within a PRINT, INPUT or LPRINT statement.
ZX Spectrum can store a single quote within a set of quotation marks like so
""some text""
produces the output:
"some text"
For the same result on the Lynx use the character code CHR$(34), for instance:
PRINT CHR$(34);"some text";CHR$(34)
or for a string variable
α$=CHR$(34)+"some text"+CHR$(34)
Nomenclature
This list uses the same letters to represent variables, expressions and sequences etc. as the ZX Spectrum BASIC manual.
α,β represents a single letter
v represents a variable
x,y,z represents numerical expressions
m,n represents numerical expressions rounded to the nearest integer
b represents a 16 bit binary number
h represents a hexadecimal number
e represents an expression
f represents a string valued expression
s represents a sequence of statement separated by colons :
c represents a sequence of colour items, each terminated by commas , or semi-colons ; A colour item has the form of a PAPER, INK, FLASH, BRIGHT, INVERSE or OVER statement.
References
Sinclair ZX Spectrum BASIC Programming, Steven Vickers (author), Robin Bradbeer (editor)
Camputers Lynx User Manual, Sue Jansons (author), Camputers Ltd (publisher)