THE SYNTAX OF ZX BASIC ====================== For those who forgot it we give here a short overview of the syntax of the Spectrum BASIC, in the usual form (simplified Backus-Nauer form): x, y, z ... represent numerical expressions x$, y$ ... represent alphanumeric expressions m, n, p ... represent numerical expressions which are rounded to the nearest integer v, v1, v2 ... represent numerical variable names à, á, ... represent a single letters ('a'..'z' or 'A'..'Z') c represent any character d represent a single digit (0..9) b represent any BASIC command [A] means 'A can be omitted' {A|B|C} means 'A or B or C' [A...] means 'A can be omitted or repeated many times' Statements: BEEP x,y BORDER m BRIGHT m CAT CIRCLE [{BRIGHT m|FLASH m|INK m|INVERSE m|PAPER m|OVER m}{;|,}...]x,y,z CLEAR [m] CLOSE #m CLS CONTINUE COPY DATA {x|x$}[,{y|y$}...] DEF FN {à([á[$][,ç[$]...]])=x|à$([á[$][,ç[$]...]])=x$} DIM à[$](m[,n ...]) DRAW [{BRIGHT m|FLASH m|INK m|INVERSE m|PAPER m|OVER m}{;|,}...]x,y[,z] ERASE x$ FLASH m FOR à=x TO y STEP z FORMAT x$ GO SUB m GO TO m IF x THEN b INPUT {x|x$|#m|AT m,n|BRIGHT m|FLASH m|INK m|INVERSE m|LINE à$[([m[,n...]][, [p] TO [q]])][([[r][ TO [s]]])...]|PAPER m|TAB m|OVER m}[{;|,|'}{y|y$|#p| AT p,q|BRIGHT p|FLASH p|INK p|INVERSE p|LINE á$[([i[,j...]][,[k] TO [l]])][([[t][ TO [u]]])...]|PAPER p|TAB p|OVER p}...} INVERSE m LET {{v|à(m[,n...])}=x|à$[([m[,n...]][,[p] TO [q]])][([[r][ TO [s]]])...]=x$} LIST {#m[,n]|[n]} LLIST {#m[,n]|[n]} LOAD x$[{CODE [m[,n]]|DATA à[$]()|SCREEN$}] LPRINT {|x|x$|#m|AT m,n|BRIGHT m|FLASH m|INK m|INVERSE m|PAPER m|TAB m|OVER m} [{;|,|'}{|y|y$|#p|AT p,q|BRIGHT p|FLASH p|INK p|INVERSE p|PAPER p|TAB p| OVER p}...] MERGE x$ MOVE x$,y$ NEW NEXT à OPEN #m,x$ OUT m,n OVER m PAPER m PAUSE m PLOT [{BRIGHT m|FLASH m|INK m|INVERSE m|PAPER m|OVER m}{;|,}...]x,y POKE m,n PRINT {|x|x$|#m|AT m,n|BRIGHT m|FLASH m|INK m|INVERSE m|PAPER m|TAB m|OVER m} [{;|,|'}{|y|y$|#p|AT p,q|BRIGHT p|FLASH p|INK p|INVERSE p|PAPER p|TAB p| OVER p}...] RANDOMIZE [n] READ {v1|à(m[,n...])|à$[([m[,n...]][,[p] TO [q]])][([[r][ TO [s]]])...]}[,{v2| á(p[,q...])|á$[([i[,j...]][,[k] TO [l]])][([[t][ TO [u]]])...]}...] REM [c...] RESTORE [m] RETURN SAVE x$[{CODE m,n|DATA à[$]()|LINE m|SCREEN$}] STOP VERIFY x$[{CODE [m[,n]]|DATA à[$]()|SCREEN$}] ZX Interface 1 statement extensions: CAT [#m{,|;}]n CLEAR # CLS # ERASE x${,|;}m{,|;}y$ FORMAT x${,|;}m[{,|;}y$] LOAD *x$[{,|;}m[{,|;}y$]][{CODE [m[,n]]|DATA à[$]()|SCREEN$}] MERGE *x$[{,|;}m[{,|;}y$]] MOVE {#m|x$[{,|;}n[{,|;}y$]]} TO {#p|z$[{,|;}q[{,|;}r$]]} OPEN #m{,|;}x$[{,|;}n[{,|;}y$]] SAVE *x$[{,|;}m[{,|;}y$]][{CODE n,p|DATA à[$]()|LINE q|SCREEN$}] VERIFY *x$[{,|;}m[{,|;}y$]][{CODE [m[,n]]|DATA à[$]()|SCREEN$}] '128 Basic' extensions: CAT ! ERASE !x$ FORMAT x$;m LOAD !x$[{CODE [m[,n]]|DATA à[$]()|SCREEN$}] MERGE !x$ PLAY x$[,y$[,z$,[r$[,s$[,t$,[u$,[w$]]]]]]]] SAVE !x$ [{CODE m,n|DATA à[$]()|LINE m|SCREEN$}] SPECTRUM VERIFY !x$[{CODE [m[,n]]|DATA à[$]()|SCREEN$}] (but this is a bug) The '128 Basic' no longer accepts some incomplete syntax forms accepted by '48 Basic' for CAT, ERASE x$ and FORMAT x$. Timex Sinclair 2068 statement extensions: CAT x$,[c...] DELETE [m],[n] ERASE x$,[c...] FORMAT x$,[c...] LOAD *x$,[c...] MERGE *x$,[c...] MOVE x$,[c...] ON ERR {GOTO x|CONTINUE|RESET} OPEN #m,x$,[c...] SAVE *x$,[c...] SOUND m,n[;p,q...] RESET [{*|#n}] VERIFY *x$,[c...] TS2068 basic also doesn't accept incomplete syntax forms for ERASE x$, FORMAT x$, CAT and MOVE x$,y$. '+3 Basic' extensions (not yet implemented into the emulation): CAT {#m[,x$]|[x$]}[EXP] COPY [{EXP [INVERSE]|x$ TO {y$|SCREEN$|LPRINT|SPECTRUM FORMAT}}] FORMAT {x$|LINE m|LPRINT x$[;y$]} MOVE x$ TO y$ PLAY x$[,y$[,z$,[r$[,s$[,t$,[u$,[w$]]]]]]]] SPECTRUM The '+3 Basic' doesn't accept '128 Basic' extensions (except the commands PLAY and SPECTRUM, because there is another method for other 128-like commands) nor ZX Interface 1 extensions, and no longer accepts wrong syntax form accepted by '48 Basic' MOVE x$,y$. That's why in '+3 Basic' some commands like LOAD, CAT, MOVE, COPY etc. have meaning which is strongly dependent on the content of their string arguments. The numerical expressions (in all Basic forms) have the following form: BIN [{0|1}...] x+y CODE x$ x-y COS x x*y EXP x x/y FN à([á[$][,ç[$]...]]) x^y IN m +x INT x -x LEN x$ (x) LN x {x=y|x$=y$} NOT x {x>y|x$>y$} x OR y {x=y|x$>=y$} POINT (m,n) {x<>y|x$<>y$} RND v SGN x à(m[,n...]) SIN x ABS x SQR x ACS x TAN x x AND y USR {x|x$} ASN x VAL x$ ATTR (m,n) The Timex Sinclair 2068 also introduces two new numerical functions: STICK (m,n) FREE The alphanumeric expressions have the following form: "[c...]" CHR$ m x$+y$ INKEY$[#m] (x$) SCREEN$ (m,n) x$([[m][ TO [n]]]) STR$ x à$[([m[,n...]][,[p] TO [q]])] VAL$ x$ x$ AND x The numbers have the form d[d...][.[d...]][{E|e}[{+|-}]d[d...]], and a numerical variable names have the form à[{á|d|_}...].