(MouseTestUtil.Jam
) .print

($help) .dup .where (.pop .pop) (256 .dict .def) .ifelse .cvx .exec

(/def)
(.exch .pop .def) .cvx .def

(/xdef)
(.exch .pop .cvx .def) .cvx .def


(/def)
("/def" accepts three entries on the stack: a key, a comment string, and a value. The comment string is discarded and the value is defined under the key in the current dictionary)
(/def) .load /def

(/xdef)
("/xdef" is like /def, except that the string is defined as executable)
(/xdef) .load /xdef

(?)
("?"	prints the explanation of the given key from the $help dictionary)
($help .exch .get =)/xdef

(??)
("??" 	prints the names of all the utility commands found in the $help 
dictionary.)
($help /kdir)/xdef

(/print)
(like .print but appends cr)
(.print (
).print).cvx /def

(=)
("="	prints the top of the stack on the default display)
((             ) .cvis .print (
).print)/xdef

(==)
(== is used to print all types of objects in a manner which can easily be 
read. The object to be printed is expected on the operand stack.
	<x> == => -- )
((!tab!) -1 .def pprint )/xdef

(pprint)
(pprint supports == and does all the printing)
(.dup .type $ptypes .exch .get .exec)/xdef

(!tc!)
0 .def

(/pause)
(/pause is used to pause the execution of a program until the user types
somthing.)
((
**Type CR to continue)= .mystream .readitem .pop .pop)/xdef

(/stk)
("/stk"	prints (without destroying) the contents of the operand stack.)
(.cntstk .dup 1 .add .copy  (.dup .type .print
       (	).print = ) .cvx .rept .pop)/xdef

(/pstk)
("/pstk"	pretty prints (without destroying) the contents of the operand stack.)
(.cntstk .dup 1 .add .copy  (==) .cvx .rept .pop)/xdef

(/clr)
("/clr"	clears the operand stack  (same as .clrstk))
(.clrstk) /xdef

(/dir)
("/dir"	prints the contents of the dictionary on top of the operand stack.)
((.exch (                    ) .cvis .print (		).print .dup .type .print (	).print =) .cvx .dictforall)/xdef

(/kdir)
("/kdir" prints the keys found in the dictionary on the top of the operand
stack.)
((.exch = .pop) .cvx .dictforall)/xdef


(/if)
("/if" is equivalent to ".cvx .if")
(.cvx .if)/xdef

(/ifelse)
("/ifelse" is equivalent to " .ifelse .cvx .exec")
(.ifelse .cvx .exec)/xdef

([)
("[" is a command that marks the operand stack for use by the command "]".
This pair of commands is use to create arrays.  For example:
[ 1 2 (hello) ] 
will create an array containing two integers (1 and 2) and the string
"hello".)
(.mark)/xdef

(])
("]" is a command that counts the elements after the mark on the stack and 
puts these elements into an array which is left on the stack. 
The pair of commands ( "[" and "]" ) is use to create arrays.  For example:
[ 1 2 (hello) ] 
will create an array containing two integers (1 and 2) and the string
"hello".)
(.cnttomrk .array .astore .exch .pop)/xdef

($commands) .dup .where (.pop .pop) (.sysdict .maxlength .dict .def) /ifelse

$commands .begin
.sysdict (.dup .itype 7 .eq (.exch .def)(.pop .pop) /ifelse).cvx .dictforall
.end

($ptypes) .dup .where (.pop .pop) (15 .dict .def) /ifelse

$ptypes .begin
(.nulltype)((nulltype -- no value)=).cvx .def
(.integertype)((integertype -- value is: ) .print =).cvx .def
(.longintegertype)((longintegertype -- value is: ) .print =).cvx .def
(.realtype)((realtype -- value is: ) .print =).cvx .def
(.booleantype)((booleantype -- value is: ) .print =).cvx .def
(.stringtype)((stringtype -- value is: ) .print =).cvx .def
(.streamtype)((streamtype -- no value)=).cvx .def
(.commandtype)((commandtype -- value is: ) .print $commands .exch .get =).cvx .def
(.dicttype)((dicttype -- length is: ).print .dup .length (         ).cvis .print ( maxlength is: ).print .maxlength =).cvx .def
(.arraytype)(tabinc tabprint(array: )= (tabprint pprint).cvx .arrayforall tabdec).cvx .def
(.stacktype)((stacktype -- no value)=).cvx .def
(.frametype)((frametype -- no value)=).cvx .def
(.marktype)((marktype -- no value)=).cvx .def
.end

(tabinc)((!tab!) .dup .load 1 .add .store).cvx .def
(tabprint)(!tab! ((	).print).cvx .rept).cvx .def
(tabdec)((!tab!) .dup .load 1 .sub .store).cvx .def

(/nestprompt)
(Redefines prompt to append a !, opens a new keystream for execution,
and then restores prompt when stream is terminated by typing LF to an
empty line)
( (.prompt) 2 .array
.dup 0 (.prompt).load .aput
.dup 1 ((!).print) .cvx .aput .cvx .def
.keystream .cvx .prompt .exec
(.prompt) .dup .load 0 .aget .def )
/xdef

(.stkundflw)((Stack underflow error) = /stk /nestprompt ) .cvx .def
(.undefkey)((**Undefined symbol: ).print = /stk /nestprompt) .cvx .def
(.longname) ((**Long File Name --file name passed to  .run or .bytestream is too long (256 chars). ) = /stk /nestprompt).cvx .def
(.badname)
((**Bad File Name -- attempt to create stream with given name.) = /stk /nestprompt).cvx .def
(.typechk)
((**Type Error -- bad arguments on stack --) = /stk /nestprompt).cvx .def
(.dictfull)
(( **Dictionary Full --an attempt to define entry into full dictionary.) = /stk /nestprompt).cvx .def
(.syntaxerr)
((**Syntax Error-- an isolated right paren has been found by the scanner.) = /stk /nestprompt).cvx .def
(.overflow)
((**Numeric Overflow-- numeric overflow has occurred in scanning a number.) = /stk /nestprompt).cvx .def
(.stkovrflw)
((**Stack Overflow-- This error may come from various parts of the JaM machine. When error occurs, all stacks are stored into arrays and put on operand stack in the order: opstack, dictstack, execstk.) = /stk /nestprompt).cvx .def
(.rangechk)
((**Range Error -- some string or array operation is attempting to store out of bounds.) = /stk /nestprompt).cvx .def

(/edit)
((!!edn) .exch .store /p).cvx .def

(/p)
(/lp .print (!!edn) .load .print /rp .print /lp .print (!!edn) .load .load .print /rp .print (
).print).cvx .def

(/r)
((!!edr) .exch .store
 (!!eds) .exch .store
(!!edn) .load .load  (!!eds) .load .search (.exch .pop (!!edr) .load .exch 3concat (!!edn) .load .exch .store)((not found)= .pop ).ifelse .cvx .exec).cvx .def

(3concat)
(3 .copy (!!eds1) .cvlit .exch .store
(!!eds2) .exch .cvlit .store
(!!eds3) .exch .cvlit .store
 .length .exch .length .add .exch .length .add .string 
(!!edn) .load .load .litchk .not (.cvx) .cvx .if (!!edos) .exch .store
(!!edos) .load  0 !!eds1 .putstring !!eds1 .length !!eds2 .putstring !!eds1 .length !!eds2 .length .add !!eds3 .putstring).cvx .def

(/lp)
(()) 0 1 .substring .def

(/rp)
(()) 1 1 .substring .def

(!!edn)().def
(!!edr)().def
(!!eds)().def
(!!eds1)().def
(!!eds2)().def
(!!eds3)().def
(!!edos)().def