home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Chipmunk Basic 3.3.9 / basic.man next >
Encoding:
Text File  |  1996-06-05  |  24.9 KB  |  969 lines  |  [TEXT/ttxt]

  1. <HTML>
  2. <HEAD>
  3. <TITLE>Chipmunk Basic Man Page</TITLE>
  4. <H1>Chipmunk Basic Man Page</H1>
  5. </HEAD>
  6. <BODY>
  7. <HR>
  8. <PRE>
  9.  
  10.     BASIC(1)        chipmunk-basic v3.3.8             BASIC(1)
  11.  
  12.  
  13.     Chipmunk BASIC - 'BASIC' language interpreter
  14.     
  15.  
  16.     SYNOPSIS    ( UNIX )
  17.  
  18.     basic [ filename ]
  19.  
  20.     DESCRIPTION
  21.  
  22.     Chipmunk basic is an interpreter for the BASIC language. If a
  23.     filename parameter is given, then the named program file is
  24.     loaded and run as a Basic program.  
  25.  
  26.     Basic commands and statements can be entered and interpreted in
  27.     immediate mode or executed as program statements when the Basic
  28.     program is run.  A built-in line number based editor allows
  29.     program input from the console keyboard.  See below for the
  30.     commands the interpreter recognizes.
  31.     
  32.     FLAGS
  33.  
  34.     none
  35.  
  36.     COMMANDS
  37.         
  38.     Standard mumbleSoft-like Basic Commands:
  39.  
  40.     load STRINGEXPR
  41.  
  42.         Load a program into memory from the named file. The
  43.         program previously in memory is erased.  All
  44.         variables are cleared.  All lines in the file must
  45.         begin with a line number.  Line numbers do not
  46.         need to be in increasing order.
  47.  
  48.  
  49.     save STRINGEXPR
  50.  
  51.         Save the current program to a named file.
  52.  
  53.     new
  54.  
  55.         Erase the program in memory.  All files are closed and
  56.         all variables are cleared.
  57.  
  58.     clear
  59.  
  60.         All  variables are cleared.  All arrays and string
  61.         variables are deallocated.
  62.  
  63.     run { LINENUM }
  64.     run { STRINGEXPR { , LINENUM } }
  65.  
  66.         Begin execution of the program at the first line, or at
  67.         the specified line.  All variables are cleared.  If a
  68.         STRINGEXPR is given then the BASIC program with that name
  69.         file is loaded into memory first.  Program lines are
  70.         executed in line number order.
  71.  
  72.     cont
  73.  
  74.         CONTinue execution of the program on the next statement
  75.         after the statement on which the program stopped execution
  76.         due to a STOP command or an error.  See BUGS section.
  77.  
  78.     goto LINENUM
  79.  
  80.         This statement will transfer control to the line number
  81.         specified.  If the program is not running, then this
  82.         command will begin execution at the specified line
  83.         without clearing the variables.  An "Undefined line"
  84.         error will occur if LINENUM doesn't exist in the program.
  85.  
  86.     list
  87.         List the whole program.
  88.  
  89.     list 1-3
  90.         List lines 1 to 2
  91.  
  92.     list -2
  93.         List lines up to 1
  94.  
  95.     list 1
  96.         List line 1
  97.     
  98.     list 2-
  99.         List lines from 2 on
  100.  
  101.     merge STRINGEXPR
  102.  
  103.         Load a program into memory.  The previous program
  104.         remains in memory; if a line exists in both programs,
  105.         the newly loaded line is kept.
  106.  
  107.     renum STRINGEXPR VAL { , VAL { , VAL { , VAL} } }
  108.  
  109.         Renumber program lines.  By default, the new sequence
  110.         is 10,20,30,... The first argument is a new initial
  111.         line number; the second argument is the increment
  112.         between line numbers. The third and fourth arguments,
  113.         if present, specify a limiting range of old line numbers
  114.         to renumber.  RENUM can be used to move non-overlapping
  115.         blocks of code.
  116.      
  117.     edit LINENUM
  118.  
  119.         Edit a single line. If the exit from the edit is via a
  120.         cntrl-c then do not change the line.
  121.             i    insert till <return>
  122.             x    delete one char
  123.             A    append to end of line
  124.  
  125.     del LINENUM [ - LINENUM ]
  126.  
  127.         Delete a line or specified range of lines. If not found
  128.         then no lines will be deleted.
  129.  
  130.     exit
  131.     bye
  132.     quit
  133.  
  134.         Terminates the basic interpreter, ending program
  135.         execution and closing all files.
  136.  
  137.  
  138.     STATEMENTS
  139.  
  140.     { let } VAR = EXPR
  141.  
  142.         Assign a value to a variable.  Variable names can be up
  143.         to 31 significant characters, consisting of letters,
  144.         digits, underscores, and an ending dollar sign. 
  145.         Variable names are case insensitive.  Variables can
  146.         hold real numbers (IEEE double) or strings of up
  147.         to 254 characters.  If the variable name ends with a
  148.         "$" it holds strings, otherwise it holds numbers.  If a
  149.         statement starts with a variable name then an implied
  150.         LET is assumed.
  151.  
  152.     print  VAL | STRINGVAL { [ , | ; ] VAL ... } { ; }
  153.     ?      VAL | STRINGVAL { [ , | ; ] VAL ... } { ; }
  154.     print # FNUM, VAL ...
  155.  
  156.         This command will print its parameters tab delimited.
  157.         If a semi-colon is used between parameters then no tab
  158.         is inserted between the parameters.  The print
  159.         output is terminated with a carriage return unless the
  160.         parameter list ends with a semi-colon.  If a file
  161.         descriptor is given then output is redirected to the
  162.         given file.  If a
  163.         
  164.             tab(VAL);
  165.             
  166.         is found in a print statement, then print output will
  167.         skip to the horizontal position specified by VAL.
  168.  
  169.     print { # FNUM, } using STRINGVAL ; VAR { [ , | ; ] VAR ... }
  170.     
  171.         Prints formatted numbers.  Legal characters for the
  172.         format string are: + * $ # . and trailing spaces.
  173.         
  174.         Examples:
  175.         
  176.             print using "**$###.##"; 1.23    ->  ****$1.23
  177.             print using "###.##"; 2.12345    ->    2.12
  178.             
  179.     input  STRINGVAR | VAR  { , VAR }
  180.     input  "prompt"; { STRINGVAR | VAR  { , VAR } }
  181.     input  { # FNUM , } { STRINGVAR | VAR { , VAR } }
  182.  
  183.         Input from the console or from the file specified by FNUM.
  184.         If the input is from the console then a prompt string can
  185.         optionally be printed.
  186.         
  187.         *** NOTE ***
  188.         
  189.         All input to string variables is "line input"; a whole
  190.         input line will be read into one string variable.  The
  191.         number of comma seperated numeric values in the input
  192.         data must be less than or equal to the number of numeric
  193.         variables in the INPUT statement.  This INPUT usage is
  194.         different from other versions Basic.
  195.  
  196.     get STRINGVAR
  197.     
  198.         Gets one character from the console keyboard.  Blocking.
  199.     
  200.     fputbyte VAL, # FNUM
  201.     
  202.         Writes one byte to the file specified by FNUM.
  203.     
  204.     get # FNUM, VAL, TYPED-VAR
  205.     
  206.         Reads one record from a random access file into VAR.
  207.     
  208.     put # FNUM, VAL, TYPED-VAR
  209.     
  210.         Write one record to a random access file from VAR.
  211.     
  212.     cls
  213.         Clear the terminals screen.  Leaves the cursor in the
  214.         upper left corner.  For Applesoft BASIC fans, the "home"
  215.         command will also do this.
  216.  
  217.     end
  218.  
  219.         Terminates program execution and returns to the command
  220.         prompt.  Not required.
  221.  
  222.     stop
  223.  
  224.         Stops the execution of the program and returns to
  225.         the command prompt.  Prints a "Break..." message.
  226.  
  227.     if EXPR then STATEMENT { : STATEMENT } { : else STATEMENT }
  228.     if EXPR then LINENUM
  229.     if EXPR
  230.  
  231.         The IF statement.  If the condition is true then the
  232.         STATEMENTS after the THEN are executed and the
  233.         statements after the ELSE are skipped.  If the
  234.         condition is false then the statements after the "else"
  235.         are executed instead.  If the item after "then" is a
  236.         line number then a goto is executed.
  237.         
  238.         If the condition is true and there is no THEN on the
  239.         same line, statements are executed until a line
  240.         with an ENDIF is found.  (block IF() ... ENDIF)
  241.  
  242.     for VAR = EXPR to EXPR { step EXPR }
  243.  
  244.         Beginning of a FOR-NEXT loop.  It takes a starting
  245.         value, a limit and an optional step argument.  If the
  246.         step value is negative, the variable counts down.  The
  247.         body of the loop is not executed if the end condition
  248.         is true initially.
  249.  
  250.         Example:
  251.             for i=1 to 10 : print i, : next i
  252.             rem prints the numbers from 1 through 10
  253.  
  254.     next { VAR }
  255.  
  256.         End of a FOR-NEXT loop.  If the termination
  257.         conditions are met then execution falls through to the
  258.         following statement, otherwise execution returns to the
  259.         statement following the FOR statement with the
  260.         corresponding index variable. If there no index variable
  261.         parameter, the innermost FOR loop is used.
  262.  
  263.     exit for
  264.  
  265.         Exits the current FOR-NEXT loop.
  266.         
  267.     while { EXPR }
  268.  
  269.         Start of a WHILE loop. The loop is repeated until EXPR
  270.         is false. If EXPR is false at loop entry, then the loop
  271.         is not executed . A WHILE loop must be terminated by a
  272.         balancing WEND statement.
  273.  
  274.     wend { EXPR }
  275.  
  276.         Terminating statement of a WHILE loop.  If EXPR is true
  277.         then exit the loop.  Only one WEND is allowed for each
  278.         WHILE.  A WHILE-WEND loop without a condition will loop
  279.         forever.
  280.  
  281.     exit while
  282.  
  283.         Exits the current WHILE-WEND loop.
  284.         
  285.     gosub LINENUM
  286.  
  287.         Transfer command to a line number. Save return address
  288.         so that the program can resume execution at the
  289.         statement after the "gosub" command.  The recursion
  290.         depth is limited only by available memory.
  291.  
  292.     return
  293.  
  294.         Returns from the most recently activated subroutine
  295.         call (which must have been called by GOSUB).
  296.  
  297.     on EXPR   goto  LINENUM { , LINENUM ... }
  298.     on EXPR   gosub LINENUM { , LINENUM ... }
  299.     on error  goto  LINENUM
  300.  
  301.         This command will execute either a goto or a gosub to
  302.         the specified line number indexed by the value of EXPR.
  303.         
  304.         If the error form is used, only one linenumber is
  305.         allowed.  LINENUM is the line to which control is
  306.         transferred if an error occurs.  A GOTO or CONT statement
  307.         can be used to resume execution.  An error inside a named
  308.         SUB subroutine cannot be resumed from or CONTinued.
  309.  
  310.     sub NAME ( VAR { , VAR ... } }
  311.  
  312.         Subroutine entry.  May be called by a CALL statement or
  313.         by NAME. A SUB subroutine must be exited by a RETURN or
  314.         END SUB statement.  There should be only one RETURN or
  315.         END SUB statement per SUB subroutine.  The variables in
  316.         the VAR list become local variables. String and numeric
  317.         arguments are passed by value; array arguments must be
  318.         pre-dimensioned and are passed by reference.
  319.         
  320.         Example:
  321.             110  x = foo (7, j)  : rem Pass 7 and j by value.
  322.             ...
  323.             2000 sub foo (x,y,z) : rem z is a local variable
  324.             2010   print x       : rem prints 7
  325.             ...
  326.             2080   foo = y+1     : rem return value
  327.             2090 end sub
  328.  
  329.  
  330.     select case EXPR
  331.     
  332.         Multi-way branch.  Executes the statements after the CASE
  333.         statement which matches the SELECT CASE expression, then
  334.         skips to the END SELECT statement.  If these is no match,
  335.         and a CASE ELSE statement is present, then execution
  336.         defaults to the statements following the CASE ELSE.
  337.         
  338.         Example:
  339.             200 select case x
  340.             210   case 2
  341.             ...
  342.             230   case 3, 4
  343.             ...
  344.             270   case else
  345.             ...
  346.             290 end select
  347.  
  348.  
  349.     dim VAR( d { , d { , d } } ) { , VAR( d { , d { , d } } ) }
  350.  
  351.         Dimension an array or list of arrays (string or numeric). 
  352.         A maximum of 4 dimensions can be used. The maximum
  353.         dimension size is limited by available memory. Legal
  354.         array subscripts are from 0 up and including the
  355.         dimension specified; d+1 elements are allocated.  All
  356.         arrays must be dimensioned before use.
  357.         
  358.         Example:
  359.             10 dim a(10)
  360.             20 for i=0 to 10
  361.             30   a(i) = i^2
  362.             40 next i
  363.             50 print a(5) : rem should print 25
  364.  
  365.     dim VAR { ( INT ) } as new CLASSNAME
  366.  
  367.         Create a record (TYPED-VAR) or object using a
  368.         previously defined structure definition type created
  369.         by TYPE...END TYPE or CLASS..END CLASS.  Optionally
  370.         creates an array of records or objects.
  371.         
  372.     erase VAR
  373.     
  374.         Un-dimensions a dimensioned array.  Frees memory.
  375.  
  376.     type CLASSNAME
  377.     
  378.         Creates a structure definition type.  Each field
  379.         requires a separate line.  Legal types are string,
  380.         integer and double.  The definition must conclude with
  381.         an END TYPE statement.  Use the DIM AS NEW statement
  382.         to create records with the specified structure.
  383.         
  384.         Example:
  385.             300 type person
  386.             310   name as string * 32 : rem 31 max length
  387.             320   age as integer
  388.             330   weight as double
  389.             340 end type
  390.             400 dim friend1 as new person
  391.             410 friend1.name = "Mark" : friend1.age = 12
  392.             420 print friend1.name, friend1.age
  393.  
  394.  
  395.  
  396.     class CLASSNAME { extends SUPERCLASSNAME }
  397.     
  398.         Creates a class definition.  Class definitions can then
  399.         be used to create objects with member functions (also
  400.         called methods.)  Classes inherit members from
  401.         superclasses (single inheritance.)
  402.         
  403.         Example:
  404.         CLASS bar
  405.           y AS integer
  406.           z AS PRIVATE double    ' private data
  407.           s AS PUBLIC string    ' public keyword optional
  408.           SUB blah(v)        ' public member function
  409.             this.y = v + 7
  410.           END SUB
  411.         END CLASS
  412.         
  413.         DIM b AS NEW bar    ' create object b
  414.         CALL b.blah(1)        ' send message "blah(1)" to b
  415.         
  416.     read VAR { , VAR }
  417.  
  418.         Read data from the DATA statements contained in the
  419.         program. List items can be either string or numeric
  420.         variables. Reading past the end the last DATA statement
  421.         generates an error.
  422.  
  423.     data ITEM { , ITEM }
  424.  
  425.         DATA statements contain the data used in the READ
  426.         statements. Items must be separated by commas.  The
  427.         items may be either numeric or string expressions,
  428.         corresponding to the type of variable being read.
  429.         Reading the wrong kind of object produces a "Type
  430.         mismatch" error.  Strings must be encapsulated with
  431.         quote marks.
  432.  
  433.     restore { LINENUM }
  434.  
  435.         The RESTORE statement causes the next READ to use the
  436.         first DATA statement in the program.  If a LINENUM is
  437.         given then the DATA statement on or after that
  438.         particular line is used next.
  439.  
  440.     rem or "`"
  441.  
  442.         A remark or comment statement.  Ignored by the program
  443.         during execution, however a REM statement can be the
  444.         target of a GOTO or GOSUB.
  445.  
  446.     open STRINGEXPR for { input|output|append } as # FNUM
  447.  
  448.         Open a file. The { input|output|append } parameter
  449.         specifies whether the file is to be read, written or
  450.         appended.  If STRINGEXPR is "stdin" for input or
  451.         "stdout" for output then the console will be used
  452.         instead of a file.  A "file not found" error will
  453.         occur if a non-existant file is specified in an OPEN
  454.         for input statement.
  455.  
  456.     open STRINGEXPR for random as # FNUM len = VAL
  457.  
  458.         Opens a random access file.  Only GET and PUT statement
  459.         are allowed to read and write random access files. 
  460.  
  461.     close # FNUM
  462.  
  463.         Close a file. Releases the file descriptor and flushes
  464.         out all stored data.
  465.  
  466.     def fnNAME ( VAR { , VAR } ) = EXPR
  467.  
  468.         Define a user definable function.
  469.         
  470.         Example:
  471.             10 def fnplus(x,y) = x+y
  472.             20 print fnplus(3,5) : rem prints 8
  473.  
  474.     { let } mid$( STRINGVAR, EXPR1, EXPR2 ) = STRINGEXPR
  475.  
  476.         Replace the sub-string in STRINGVAR, starting at
  477.         character position EXPR1 with character length EXPR2,
  478.         with the string STRINGEXPR.
  479.  
  480.     { let } field$( STRINGVAR, VAL { ,STRINGVAL } ) = STRINGEXPR
  481.  
  482.         Replace the N-th field of STRINGVAR with STRINGEXPR.
  483.  
  484.     exec(STRINGEXPR)
  485.  
  486.         Executes STRINGEXPR as a statement or command. 
  487.         e.g. exec("print " + "x") will print the value of x.
  488.  
  489.     poke ADDR_EXPR, DATA_EXPR
  490.  
  491.         Poke a byte into a memory location. Unreasonable
  492.         addresses can cause bus or segmentation errors.
  493.  
  494.     push VAR { , VAR ... }
  495.  
  496.         Pushes one or more expressions or variables onto an
  497.         internal stack.  Expressions can be returned using the
  498.         POP function; variables can be returned by using the
  499.         POP statement.
  500.     
  501.     pop VAL
  502.  
  503.         POP statement (see also POP function). Pops VAL
  504.         variables off the internal stack, restoring the value
  505.         of those variables to their pushed values.
  506.     
  507.     NUMERIC FUNCTIONS
  508.  
  509.     sgn(VAL)
  510.  
  511.         Returns the sign of the parameter value.  Returns 1 if
  512.         the value is greater than zero , zero if equal to zero.
  513.         -1 if negative.
  514.  
  515.     abs(x)
  516.  
  517.         Returns the absolute value of x.
  518.  
  519.     int(x)
  520.  
  521.         Returns the integer value of x.  Truncates toward zero.
  522.         The absolute value of x must be less than 2^31-1.
  523.  
  524.     floor(x)
  525.  
  526.         Returns the integer value of x.
  527.         Truncates toward negative infinity.
  528.  
  529.     sqr(x)
  530.  
  531.         Returns the square root of x.
  532.  
  533.     log(x)
  534.  
  535.         Returns the natural logarithm of x.
  536.  
  537.     log10(x)
  538.  
  539.         Returns the logarithm base 10 of x.
  540.  
  541.     exp(x)
  542.  
  543.         Returns e^x. e=2.7182818...
  544.  
  545.     sin(x)
  546.     cos(x)
  547.     atn(x)
  548.  
  549.         Trigonometric functions: sin, cosine and arctangent. 
  550.  
  551.     pi
  552.     
  553.         Returns pi, 3.141592653589793... 
  554.  
  555.     rnd ( EXPR )
  556.  
  557.         Returns a random number between 0 and int(EXPR)-1
  558.         inclusive. If EXPR is 1, then returns a fraction between
  559.         0 (inclusive) and 1.  If EXPR is negative then EXPR
  560.         seeds the random number generator.
  561.  
  562.     randomize EXPR
  563.  
  564.         Seeds the random number generator with the integer EXPR.
  565.  
  566.     len( STRINGEXPR )
  567.  
  568.         Returns the length of the string STRINGEXPR.
  569.  
  570.     len( TYPED-VAR )
  571.  
  572.         Returns the length, in bytes, of a typed record
  573.         (one created by DIM AS).
  574.  
  575.     val( STRINGEXPR | EXPR )
  576.  
  577.         Value of the expression contained in a STRINGEXPR or
  578.         EXPR.  STRINGEXPR may be a string literal, variable,
  579.         function, or expression.
  580.         
  581.         For example, VAL("1 + sqr(4)") yields 3.
  582.  
  583.     asc( STRINGEXPR )
  584.  
  585.         Returns the ascii code for the first character of
  586.         STRINGEXPR.  A null string returns zero.
  587.  
  588.     instr(a$, b$ { , VAL } )
  589.  
  590.         Returns the position of the substring b$ in the
  591.         string a$ or returns a zero if b$ is not a substring.
  592.         VAL is an optional starting position in a$
  593.  
  594.     ubound ( VAR )
  595.     
  596.         If VAR is a dimensioned 1D array, return the maximum
  597.         legal subscript of that array, else returns 0.
  598.  
  599.     eof(FILENUM)
  600.  
  601.         Returns true if the file specified by FILENUM has
  602.         reached the end of the file.
  603.  
  604.     fgetbyte(FILENUM)
  605.  
  606.         Reads one byte from the file specified by FILENUM.
  607.         Useful for reading non-ASCII values.
  608.  
  609.     pop
  610.  
  611.         POP function (see also POP statement). Pops one variable
  612.         value off the stack and returns that value (string or
  613.         numeric).
  614.         
  615.         (POP can be used as either a statement (with a
  616.         parameter) or a function (no parameter). Note that the
  617.         POP function, unlike the POP statement, does not
  618.         restore the value of the variable pushed, but only
  619.         returns the pushed value.  This use of the POP
  620.         statement is different from the Applesoft usage.)
  621.  
  622.     peek( ADDR { , VAL } )
  623.  
  624.         Returns the value of the byte in memory at address ADDR.
  625.         If VAL is 2 or 4, returns the value of the 16-bit or
  626.         32-bit word respectively (if correctly aligned).
  627.         If VAL is 8, returns the value of the numeric variable
  628.         located at ADDR.  peek(varptr(x),8) equals x.
  629.  
  630.     varptr( VAR | STRINGVAR )
  631.     
  632.         Returns the memory address of a variable.
  633.     
  634.     erl
  635.  
  636.         Returns the line number of the last error.  Zero if the
  637.         error was in immediate mode.  The variable errorstatus$
  638.         gives the error type.
  639.  
  640.     timer
  641.  
  642.         Returns a numeric value of elapsed of seconds from the
  643.         computers internal clock.
  644.  
  645.     
  646.     STRING FUNCTIONS
  647.  
  648.     x$ + y$
  649.  
  650.         String concatenation.  The result must be 254 characters
  651.         or less in length.
  652.     
  653.     chr$(VAL)
  654.  
  655.         Returns the ascii character corresponding to the value
  656.         of VAL.
  657.  
  658.     str$( VAL { , EXPR } )
  659.  
  660.         Returns a string representation corresponding to VAL.
  661.         If EXPR is present then the string is padded to that
  662.         length.
  663.  
  664.     inkey$
  665.  
  666.         Return one character from the keyboard if input is
  667.         available. Returns a zero length string { "" } if no
  668.         keyboard input is available.  Non-blocking.  Can be used
  669.         for keyboard polling.
  670.  
  671.     input$( EXPR { , FILENUM } )
  672.  
  673.         Returns EXPR characters from file FILENUM. If f is not
  674.         present then get input from the console keyboard.
  675.  
  676.     mid$( a$, i { , j } )
  677.  
  678.         Returns a substring of a$ starting at the i'th
  679.         positions and j characters in length. If the second
  680.         parameter is not specified then the substring is taken
  681.         from the start position to the end of a$.
  682.  
  683.     right$(a$, EXPR )
  684.  
  685.         Returns the right EXPR characters of a$.
  686.  
  687.     left$(a$, EXPR )
  688.  
  689.         Returns the left EXPR characters of a$.
  690.  
  691.     field$( STRINGVAL, VAL { , STRINGVAL } )
  692.  
  693.         Returns the N-th field of the first string.  If the
  694.         optional string is present then use the first character
  695.         of that string as the field separator.  The default
  696.         separator is a space.  Similar to UNIX 'awk' fields.
  697.         
  698.         e.g.  field$("11 22 33 44", 3)  returns  "33"
  699.  
  700.     hex$( VAL { , EXPR } )
  701.     bin$( VAL { , EXPR } )
  702.  
  703.         Returns the hexadecimal or binary string representation
  704.         corresponding to VAL.  If EXPR is present then the
  705.         string is padded with zeros to make it that length.
  706.  
  707.     lcase$( STRINGVAL )
  708.  
  709.         Returns STRINGVAL in all lower case characters.
  710.  
  711.     errorstatus$
  712.  
  713.         Returns the error message for the last error.
  714.  
  715.  
  716.     OPERATORS
  717.  
  718.     The following mathematical operators  are available:
  719.  
  720.         ^    exponentiation
  721.         *    multiplication
  722.         /    division
  723.         mod    remainder
  724.         +    addition
  725.         -    subtraction
  726.  
  727.     logical operators: (any non-zero value is true)
  728.  
  729.             not    logical not
  730.  
  731.     bitwise operators:
  732.  
  733.             and    bitwise and
  734.             or    bitwise or
  735.             xor    bitwise exclusive-or
  736.  
  737.     comparison operators:
  738.  
  739.             <=    less than or equal
  740.             <>    not equal to
  741.             >=    greater than or equal
  742.             =    equal
  743.             >    greater than
  744.             <    less than
  745.  
  746.     x$=y$, x$<y$, x$>y$, x$<=y$, x$>=y$, x$<>y$
  747.  
  748.         String comparisons; result is 1 if true, 0 if false.
  749.         
  750.     Operator precedence (highest to lowest):
  751.  
  752.         ( )
  753.         not -{unary_minus} functions
  754.         ^
  755.         * / mod
  756.         + -
  757.         = < > <= >= <>
  758.         and
  759.         or xor
  760.  
  761.     
  762.     UNIX functions:
  763.  
  764.     sys( STRINGVAL )
  765.  
  766.         UNIX system call.  The string parameter is given to
  767.         the shell as a command.  Returns exit status.
  768.  
  769.     getenv$( STRINGVAL )
  770.          
  771.         Returns value for environment name STRINGVAL.
  772.               
  773.     argv$
  774.         Returns the UNIX shell command line arguments.
  775.  
  776.  
  777.     Macintosh commands:
  778.  
  779.     *** NOTE ***
  780.     
  781.         Many MacOS specific functions and commands are only
  782.         documented in the Chipmunk Basic quick reference file.
  783.  
  784.     gotoxy VAL, VAL
  785.  
  786.         Set the horizontal and vertical location of the
  787.         text output cursor.  (0,0) is the upper left corner.
  788.  
  789.     moveto VAL, VAL
  790.  
  791.         Sets the (x,y) location of the graphics pen.
  792.  
  793.     lineto VAL, VAL
  794.  
  795.         Draws a line from the current pen location to location
  796.         (x,y) in the graphics window.
  797.  
  798.     window x, y, char_cols, char_lines
  799.  
  800.         Change the text console window position and size.
  801.  
  802.     call "bigfont"
  803.     
  804.         Toggle the BIGFONT console output status make the
  805.         default text font bigger or smaller.
  806.     
  807.     morse STRINGVAL { , VAL, VAL, VAL, VAL }
  808.  
  809.         Plays morse code through the speaker.
  810.         The parameters are: dot-speed-wpm, volume{0..100},
  811.         word-speed-wpm, frequency{in Hz or cps}
  812.  
  813.     sound VAL, VAL, VAL 
  814.  
  815.         The parameters are:
  816.         frequency{in Hz}, seconds_duration, volume{0..100}
  817.     
  818.     say STRINGVAL
  819.  
  820.         Speaks STRINGVAL if the Speech Manager Extension is
  821.         resident.  Try "say a$,200,46,1" for faster speech.
  822.  
  823.     open "SFGetFile" for input  as #FNUM
  824.     open "SFPutFile" for output as #FNUM
  825.  
  826.         Puts up a standard file dialog for the file name.
  827.  
  828.     files { STRINGVAL }
  829.     
  830.         Displays a listing of files in the named or current
  831.         directory.
  832.     
  833.     Macintosh functions:
  834.     
  835.     fre
  836.         Returns the amount of memory left for program use. 
  837.     
  838.     date$
  839.         Returns a string corresponding to the current date.
  840.  
  841.     time$
  842.         Returns a string corresponding to the current time.
  843.  
  844.     pos(VAL)
  845.  
  846.         Returns the horizontal position of the text cursor.
  847.         If VAL is negative returns the vertical position.
  848.     
  849.     errorstatus$
  850.     
  851.         Also returns the full path name of the program and
  852.         files opened by SFGetFile. (under System 7 and only
  853.         if the name fits in a string variable)
  854.     
  855.     
  856.     Macintosh menu items:
  857.  
  858.     Open or <cmd>O     will put up a dialog to allow selection
  859.             of a program file to load.  Basic Program file
  860.             names must end with a ".bas" suffix.
  861.  
  862.     Copy        will allow copying picts from the graphics
  863.             window.
  864.     
  865.     <cmd>.         Command-period will stop program execution.
  866.  
  867.     Print        Print graphics window if it's the frontmost
  868.             window. Only the graphics window can be printed.
  869.  
  870.  
  871.     RESERVED WORDS AND SYMBOLS
  872.  
  873.     + - * / ^ mod  and or xor not  > < >= <= <> = ()
  874.     sqr log exp sin cos tan atn  pi
  875.     abs sgn int rnd peek val asc len
  876.     mid$ right$ left$ str$ chr$  lcase$ ucase$
  877.     goto  if then else endif  gosub return
  878.     for to step next  while wend  select case
  879.     rem  let  dim erase  data read restore   field$
  880.     input print open for output append as close# load save
  881.     random lof loc get put   
  882.     inkey$  input$ eof  files  fgetbyte# fseek# fputbyte
  883.     run stop end exit quit cont  renum  new clear
  884.     date$ time$ timer  sound morse say  doevents
  885.     home cls gotoxy htab vtab pos 
  886.     graphics sprite pset moveto lineto window scrn mouse
  887.     varptr peek poke fre push pop  isarray
  888.     sub call usr  def fn
  889.     type class extends  string integer single double
  890.     asin acos sinh cosh tanh log10 floor true false ubound
  891.     
  892.     msgbox  do loop until break  function
  893.     method private public local   menu dialog memstat()
  894.     draw play  bload bsave min max mat
  895.     each redim resume  static
  896.     eqv imp key is each option set width swap
  897.  
  898.     CONVENTIONS
  899.  
  900.     EXPR        an expression that evaluates to a numeric value.
  901.     STRINGEXPR    a string expression.
  902.     VAR        a numeric variable.
  903.     STRINGVAR    a string variable. Name must end with a "$".
  904.     INTEGERVAR    a 16-bit variable. Name must end with a "%".
  905.     
  906.     All program lines must begin with a line number.  A line number
  907.     entered by itself will delete that program line. Using spaces
  908.     (indentation) between the line number and program statements is
  909.     legal.  Line numbers can be between 1 and 2147483647.
  910.     
  911.     Hexadecimal numbers can be entered by preceding them with
  912.     a "0x" as in 0x02ae, or by "&h" as in &h0172.
  913.     
  914.     Multiple statements may be given on one line, separated by
  915.     colons:
  916.  
  917.         10 INPUT X : PRINT X : STOP
  918.  
  919.  
  920.     DIAGNOSTICS
  921.  
  922.     Some errors can be caught by the user program using the
  923.     "on error goto" command. If no error trapping routine has been
  924.     supplied then program execution is terminated and a message is
  925.     printed with the corresponding line number.
  926.  
  927.     Graphics may require that the preferred memory requirements be
  928.     increased using the Finder "Get Info" dialog box.
  929.  
  930.  
  931.     AUTHORS
  932.     
  933.     David Gillespie wrote basic.p 1.0 and the p2c lib.
  934.     Ron Nicholson (rhn@netcom.com) added file i/o, graphics and
  935.     did the Unix, Macintosh and PowerMac port.  (1990-1995Nov)
  936.  
  937.     
  938.     BUGS
  939.  
  940.     Many.
  941.  
  942.     Can't CONTinue from an error inside a named SUB subroutine.
  943.     
  944.     The PRINT USING format string doesn't recognize comma's or
  945.     underscores.
  946.     
  947.     Integer VARs, like i%, don't work in FOR-NEXT statements.
  948.     Integer arrays can only have a dimension of one and will only
  949.     work in assignment (LET) statements.  All arithmetic on integer
  950.     variables is done using floating point arithmetic.
  951.  
  952.     Macintosh screen editing will only recognise the last line
  953.     modified before a RETURN or ENTER key.  The EDIT command and
  954.     screen editing are incompatible.
  955.  
  956.     There are many undocumented graphics and sprite commands
  957.     and keywords in the Macintosh port.  See the accompanying
  958.     README and Chipmunk Basic quick-reference file.
  959.  
  960.  
  961.     Portions Copyright (C) 1989 Dave Gillespie
  962.     Copyright (C)1994,1996 Ronald H. Nicholson, Jr. (rhn@nicholson.com),
  963.     All rights reserved.
  964.     "Applesoft" is a trademark of Apple Computer, Inc., etc.
  965.  
  966. </PRE>
  967. </BODY>
  968. </HTML>
  969.