	basic is not yet in its final form.  if you see a change you
feel is needed, or a bug, post staylor with details.

to run basic:

& newbasic

---

features missing:

implicit array and vector dimensioning.  instead, dimension each array explicitly


---

list of top-level commands:

<eot><eot>			control d causes basic to quit
sys			also causes basic to quit
old filename		reads and compiles filename (extension, if any, must
			  be given, e.g. old harry.bas )
new filename		specifies filename for subsequent saves
quiet			turns of the "ready" message for subsequent commands
ready			restores the "ready" message
scratch			clears out core
oldata filename		reads a file for editting only
newdata filename
weave filename		merges a file into the execution image
list line,line		types a portion of the file as modified on the terminal
ldif line,line		types only the modification line
type filename		types a file on the terminal
catalog			types the users current directory
save filename		write the modified program to a new file
replace filename	same as save, but for previously existing file
asave			write a a.out file named "a.out"
compile line,line	re-compile indicated lines
shell			start up a subshell
time			type out timing information
length			print out core usage summary information
run			execute the incore program

print,let,goto	may also be executed at the top level

---

list of verbs:

:			specifies a format template
	5: the answer is ##.##

call			invoke a function
	8 call=indir4(0,1,0,0)	'actually this is an
			 assignment, and call receives the value of the function

def			define a function
	10 def p
	11 p=t(c)
	12 c=c-1	'count down the stack pointer
	13 fnend

des			define a store function (used on left hand side of
				assignments)
	20 des s	'this is a stack routine
	21 c=c+1	'increment the stack pointer
	22 t(c)=s	'store the value on the stack
	23 fnend

dff			define function from file.  at this time, file should be
			 a.out file, containing position - independent code.

	30 dff s9$(a$,x%,y%) as file /fs/a/ss/staylor/test/seg
	31 rem define a function s9$ of 3 args. the definition is in file seg, in the library directory

dim			reserve space for arrays
	40 dim t(12),b(7,13),c$(40),i%(32)

dim #			associate a file channel number with virtual array names
	45 dim #1, f(10000), g(5000)

fnend			ends a function definition-- see examples above

for			loop specifier
	50 for a=1 to 13 step 3.5
	60 for i%=1 to 7
	70 input b(i%,a)
	80 next i%
	90 next a

goto			transfers control
	100 goto 110

gosub			subroutine call
	110 gosub 500

if			conditional statement
	120 if 1>b(3,5) then b(3,5)=2
	130 if p<>0 then s=t(c+1)\S=5 else s=5

input			terminal and file input statment
	140 input a$
	150 open a$ for input as file 2
	130 input #2, c$(1)

let			assignment statement
	let b$="time of day"
	175 c$=b$

	180 stop

mat			matrix manipulation statements
	200 mat a=b	'matrix assignment stmt
	210 mat a=(5)*b	;scalar multiply
	220 mat a=(sin(pi/4))+b	;adds a value to each element of b, and stores result in corresponding element of a
	230 mat a=zer	'set a to all zeros
	240 mat a=idn	'make a an identity matrix
	250 mat a=con
	260 mat a=inv(b)	'invert b matrix
	270 mat a=trn(b)	'set a to transpose of b
	280 mat a=b*c		'matrix multiply
	290 mat a=b:c
	300 mat a=b+c		;matrix addition
	310 mat a=b/(30)	'divide individual elements by expression

				the mat operations call upon functions
				which must be defined, either by def or dff
				see below for further comments

on			computed goto statement
	480 on sgn(p)+2 goto 180,530,500

open			data file specification statement
	500 open "common" as file 1
	510 rem open <string> [for input ! for output !!] as file [#] <number> [buffercount <number>] [size <number>]

option type		'set default type of variables
	515 option type float	'this is normal default anyway

pause			return to top-level of basic without closing files
	520 c=0
	530 pause	'presumably the user will continue with a goto lcommand

print			terminal and file output statement
	540 print tab(50) "c="c

print using		formatted output statement
	550 print using 5:c
	551 print using " ## it is ",c

randomize		re-seed the random number generator, rnd

	555 randomize

rem			remark statement
	560 rem chaos and disorder
	561 'comments may also be inserted with single-quote

return			gosub return satement
	570 return

stop			return to top-level of basic, and print "ready"
	999 stop	'this stop is 1) inaccessible, 2) unnecessary

sys			return to shell without stopping in basic
	1000 sys	'dont put one of these in unless you have saved your
			'program.
type			'declare type of varibles
	1001 type double joe,mary


---

list of library functions:

abs(x)			absolute value
baddrs(a$)		base address of string, used for unix calls
atn(x)			arctangent fcn
chr$(i)			returns one-character string
cos(x)			cosine of x
errno(0)		error of most recent sys call.
fildes(c)		unix handle corresponding to basic channel #c
exp(x)			exponential function, e^x
fpa(x)			fractional part of x
indir4(r,c,a1,a2)	does $indir unix call with r in r0, trap c the indicated unix call, a1 and a2 the arguments
int(x)			greatest integer less than x
ldimf(mat a)		left-hand dimension of a
len(a$)			length of string
log(x)			natural logarithm of x
logx(x)			log base 10 of x
log10(x)		log base 10 of x
pos(a$,b$,c)		column of first appearance of b$ in a$ after column c
rdimf(mat x)		right-hand dimension of mat x
rnd			returns a random number in range 0-1.
seg$(a$,b,c)		segment of a$ from the b-th to the c-th character
sin(x)			sin of x
sgn(x)			signum of x.  has value -1 when x is negative
				0 when x is zero, and 1 when x is positive
sqr(x)			sqr root of x


---

more about the mat statements

the mat statements are in the process of growth. at the moment there
is no provision for changing the size of the result matrix, although
that may be along soon.

partly because the growth process is not complete, the mat
verb calls upon functions which may be user-defined.
thus the algorithms are very easily subject to modification,
improvement, and debugging.

for example, suppose a program contains the line:

	1 mat a=b

if the function mtcpff   (mat copy float to float)  is not defined,
this line will generate an error message, which will indicate the required subroutine.

the user may then weave in the indicated routine from dsk, and
re-compile the offending line(s)

as:

	weave /fs/a/ss/staylor/matfns
	compile 1

note that weave has the property of "invisibility"-- a file
which has been weave'd in does not appear in the program listing.
if it is desired to merge the function definitions into the
program, this may be done with the monitor "cat" command.

not all of the mat functions have been written yet.  feel free
to post ideas, etc. to staylor.

---

basic now contains some handles on unix calls.

the file /fs/a/ss/staylor/syscal is an illustration of one game played
with these new handles.  perhaps i'll add a few more functions some dark night.
