BBC BASIC for the PDP11 ======================= Commands ======== AUTO [start][,inc] Generate line numbers. BPUT#chan,exp Write a byte to an open file. BPUT#chan,string[;] Write a string to an open file. CALL address[,arg list] Call assembly language routine. CHAIN str Load and run program. CLEAR Clear variables and reset stack. CLOSE#chn Close the open file. CLG Clear the screen graphics area. CLS Clear the screen text area. COLOUR l Select a text colour. COLOUR l,p Map a logical colour to a physical colour. COLOUR l,r,g,b Map a logical colour to an RGB colour. DATA list Data for READ statement. DEF FNname[(arg list)] Define a function. DEF PROCname[(arg list)] Define a procedure. DELETE start,end * ToDo: Delete program lines. DIM var(sub1[,sub2...])[,..] Dimension one or more arrays. DIM var exp [,...] Reserve space in heap. DIM var LOCAL exp [,...] * ToDo: Reserve space on stack. DRAW x,y Draw a line to (x,y). END Terminate program. ENDPROC Return from a procedure ENVELOPE a,b,c,d,e,f,g,h,i,j,k,l,m,n ERROR [EXT] n,string Generate an error. EXT#chn=exp Set the extent of the open file. FOR var=exp TO exp [STEP exp] Begin a FOR...NEXT loop. GCOL [m,],c Select a graphics colour. GOSUB exp Call a BASIC subroutine. GOTO exp Branch to specified line. HIMEM=exp Set top of memory used by BASIC. IF exp THEN stmts [ELSE stmts] Do statement(s) if exp non-zero. INPUT [LINE]["prompt"[,]]var[,var] INPUT#chn,var[,var...] Read data from an open file. [LET] var = exp Assignment. [LET] ^var = exp (extension). LIST [line][,line] List all or part of program. LISTO number Control indentation in LIST and text loading. LOAD "filename" Load a program into memory. LOCAL var[,var...] Declare variables local to function or procedure. LOCAL ERROR Localise error handler. LOCAL DATA Localise DATA pointer. LOMEM=exp Set start address of heap and clears dynamic variables. MODE n Select a screen mode. MOVE x,y Move the graphics cursor to (x,y). NEW Delete current program & variables. NEXT [var[,var...]] End FOR...NEXT loop. OFF Turn cursor off. ON Turn cursor on. ON exp GOTO line,line.. [ELSE line] Computed GOTO. ON exp GOSUB line,line.. [ELSE line] Computed GOSUB. ON exp PROCname.. [ELSE PROCname] * ToDo: Computed PROC call. ON ERROR LOCAL stmts Localised error handler ON ERROR stmts Do statement(s) on error. ON ERROR OFF Restore default error handling. OLD Recover a program deleted by NEW. OSCLI string Execute command. PAGE=exp Set memory address of current user's program. PLOT [k,]x,y Plot a point or other plot operation. PRINT [TAB(x[,y])][SPC n]['][;][~][#][/][exp[,exp...][;] PRINT#chn,exp[,exp...] Write data to an open file. PROCname[(parameter list)] Call a procedure. PROC(exp)[(parameter list)] Indirectly call a procedure. PTR#chn=exp Set the current pointer for an open file. PUT port,value QUIT [n] Terminate the program, returning to the caller. READ var[,var...] Read data from DATA statement(s). REM any text Remark RENUMBER [start][,inc] * ToDo: Renumber the program lines. REPEAT Begin a REPEAT...UNTIL loop. REPORT Print error message for last error. RESTORE [line] Reset data pointer to beginning or to specified line. RESTORE DATA Restore localised DATA pointer. RESTORE ERROR Restore localised error handler. RETURN Return from subroutine. RUN Run the current program. RUN str Load and run program. SAVE ["filename"] Save the current program. SOUND OFF Turn sound off. SOUND ON Turn sound on. SOUND channel,loudness,pitch,duration STOP Stop program and display message. TIME=exp TIME$=string TRACE ON Start trace mode. TRACE OFF End trace mode. TRACE exp Trace lines less than exp. UNTIL exp Terminate loop if exp is non-zero. VDU exp[,|;[exp...]][|] Send a series of bytes or words to the VDU. WIDTH exp Set print output width. Functions ========= "text" Constant string. $ num cr-terminated string indirection. $$ num null-terminated string indirection. ? num 8-bit indirection ! num 32-bit indirection | num 40-bit indirection - num Unary minus + num Unary plus ^ var Address of variable ABS num Absolute value of numeric value. ACS num * ToDo: Arc-cosine of numeric value, in radians. ADVAL channel Returns information about input devices or buffer. ASC str Returns ASCII value of string or -1. ASN num * ToDo: Arc-sine of numeric value, in radians. ATN num * ToDo: Arc-tangent of numeric value, in radians. BGET#chn Read a byte from a channel. CHR$ num Returns one-character string with ASCII value of exp. COUNT Returns number of characters printed since last new line. COS num * ToDo: Cosine of radian numeric value. DEG num * ToDo: Value in degrees of radian numeric value. DIM(array()) Returns number of dimensions of array. DIM(array(index)) * ToDo: Return size of dimension. END Returns first address after end of BASIC's variable heap. ERL Returns line number of last error. ERR Returns error number of last error. EOF#chn Return FALSE if not yet at the end of the opened file. EVAL str Evaluates str as an expression. EXP num * ToDo: e raised to the power of numeric value. EXT#chn Return the total length of the opened file. FALSE Returns zero. FNname[(parameter list)] Call named user-defined function. FN(exp)[(parameter list)] Indirectly call user-defined function. GET/GET$ Waits for keypress. GET$#chn Read a - or -terminated string from an open file. GET(port) * ToDo: Reads a value from the specified I/O port. GET(x,y)/GET$(x,y) * ToDo: Reads a character from the specified screen position. HIMEM Returns top of memory used by BASIC. INKEY/INKEY$ exp Read keypress or keyscan. INSTR(r,s[,n]) Returns position of string s in string r, INT num Largest integer less than numeric value num. LEFT$(str,exp) Returns leftmost exp characters of string. LEFT$(str) * ToDo: Returns leftmost LEN(str)-1 characters of string. LEN str Returns length of string (0-255). LN num * ToDo: Natural logarithm of numeric value. LOG num * ToDo: Base-ten logarithm of numeric value. LOMEM Returns start address of dynamic variable storage. MID$(str,m[,n]) Returns sub-string from position m, of length n or to end. MODE Returns current screen mode. NOT One's complement (integer). OPENIN str Open a file for reading. OPENOUT str Open a file for writing. OPENUP str Open a file for update (reading and writing). OSCLI str Execute command and return exit value. PAGE Returns memory address of current user's program. PI Returns 3.14159265. POINT(x,y) Returns the colour of the screen at the coordinates. POS Returns current horizontal position of the text cursor. PTR#chn Return the current pointer for an open file. QUIT Returns TRUE if running in non-interactive/editing mode. RAD num * ToDo: Radian value of numeric value in degrees. REPORT$ Returns error message for last error. RIGHT$(str,exp) Returns rightmost exp characters of string. RIGHT$(str) * ToDo: Returns rightmost one character of string. RND returns random 32-bit integer. RND(-n) seeds sequence. RND(0) repeats last value in RND(1) form. RND(1) returns number between 0 and 0.999999999 RND(n) returns random integer between 1 and n. SGN num 1 if num>0, 0 if num=0, -1 if num<0. SIN num * ToDo: Sine of radian numeric value. SQR num Square root of numeric value. *ToDo: reals roots STR$[~|=|/] num Returns string representation in decimal, hex, octal or binary. STRING$(n,str) Returns a string consisting of n copies of str. TAN num * ToDo: Tangent of radian numeric value. TIME Returns the system elapsed time clock in centiseconds. TIME$ Reads the system real-time clock as a string TOP Returns first address after end of user's program. TRUE Returns -1. USR Calls a machine code routine and returns integer. VAL str Returns numeric value of str or zero. VDU num Returns the VDU variable at offset num. VPOS Returns the vertical position of the text cursor. WIDTH Returns print output width. Operators ========= Symbol Function ------------------ var ? num 8-bit indirection var ! num 32-bit indirection var | num 40-bit indirection + Addition or string concatenation. - Negation or subtraction. * Multiplication. / Division. ^ * ToDo: Raise to power. EOR Bitwise exclusive-OR (integer). OR Bitwise OR (integer). AND Bitwise AND (integer). MOD Modulus (integer result). DIV Integer division (integer result). = Equality. <> Inequality. < Less than. > Greater than. <= Less than or equal. >= Greater than or equal. Error codes =========== Immediate mode only: 0 Silly 0 RENUMBER space 0 LINE space Untrappable: 0 No room 0 Sorry 0 STOP Bad program Trappable: 4 Mistake 4 Missing = 5 Missing , 6 Type mismatch 7 Not in a function 9 Missing " 10 Bad DIM 11 DIM space 12 Not LOCAL 13 Not in a PROC 14 Array 15 Subscript 16 Syntax error 17 Escape 18 Division by zero 19 String too long 20 Too big 21 -ve root 22 Log range 23 Accuracy lost 24 Exp range 26 No such variable 27 Missing ) 28 Bad HEX, OCT or BIN 29 No such FN/PROC 30 Bad call 31 Arguments 32 Not in a FOR loop 33 Can't match FOR 34 Bad FOR variable 35 Bad STEP 36 Missing TO 38 No GOSUB 39 ON syntax 40 ON range 41 No such line 42 Out of DATA 43 No REPEAT 45 Missing # 54 ERROR/DATA not LOCAL 190 Directory full 192 Too many open files 192 Can't save file 196 File exists 198 Disk full 200 Close error 202 Data lost 204 Bad name 214 File not found 222 Channel 223 End of file 242 Bad memory access 243 Bad word access 253 Bad string 254 Bad command