Apple II User Manual

Page of 257
                FNJ7, FNKO, FNR2.  User defined func-
                tions are restricted to one line.  A function
                may be defined to be any expression, but
                may only have one argument.  In the
                example, B and C are variables that are used
                in the program.  Executing the DEF state-
                ment defines the function.  User defined
                functions can be redefined by executing
                another DEF statement for the same
                function.  "V" is called the dummy variable.
                Execution of this statement following the               100 Z=FNA(3)
                above would cause Z to be set to 3/B+C,
                but the value of V would be unchanged.
STATEMENT       SYNTAX/FUNCTION                                         EXAMPLE
DIM             DIM variable (size 1, [size 2...])                      113 DIM A(3),B(10)
                Allocates space for matrices.  All matrix
                elements are set to zero by the DIM
                statement.
                Matrices can have from one to 255                       114 DIM R3(5,5),
                dimensions.                                             D$(2,2,2)
                Matrices can be dimensioned dynamically                 115 DIM Q1(N),Z(2*I)
                during program execution.  If a matrix is
                not explicitly dimensioned with a DIM
                statement, it is assumed to be a single
                dimensioned matrix of whose single
                subscript may range 0 to 10 (eleven
                elements).
                If this statement was encountered before a              117 A(8)=4
                DIM statement for A was found in the
                program, it would be as if a DIM A(10)
                had been executed previous to the execu-
                tion of line 117.  All subscripts start at
                zero (0), which means that DIM X(100)
                really allocates 101 matrix elements.
STATEMENT       SYNTAX/FUNCTION                                         EXAMPLE
END             END                                                     999 END
                Terminates program execution without
                printing a BREAK message.  (See STOP.)
                CONT after an END statement causes
                execution to resume at the statement after
                the END Statement.  END can be used
                anywhere in the program, and is optional.
STATEMENT       SYNTAX/FUNCTION                                         EXAMPLE
FOR             FOR variable = expression to expression                 300 FOR V=1 TO 9.3
                [STEP expression]  (See NEXT statement)                 STEP .6
                V is set equal to the value of the expression
                following the equal sign, in this case 1.  This
                value is called the initial value.  Then the
                statements between FOR and NEXT are
                executed.  The final value is the value of the
                expression following the TO.  The step is
                the value of the expression following STEP.
                When the NEXT statement is encountered,
                the step is added to the variable.
                If no STEP was specified, it is assumed to              310 FOR V=1 TO 9.3
                be one.  If the step is positive and the new
                value of the variable is <= the final value
                (9.3 in this example), or the step value is
                negative and the new value of the variable