Apple II User Manual

Page of 257
    2.  THIS IS PROBABLY THE MOST IMPORTANT SPEED HINT.
        Use variables instead of constants.  It takes more time to convert a constant to its
        floating point representation than it does to fetch the value of a simple or matrix
        variable.  This is especially important within FOR...NEXT loops or other code that
        is executed repeatedly.
    3.  Variables which are encountered first during the execution of a BASIC program are
        allocated at the start of the variable table.  This means that a statement such as
        5 A=0:B=A:C=A, will place A first, B second, and C third in the symbol table
        (assuming line 5 is the first statement executed in the program).  Later in the program,
        when BASIC finds a reference to the variable A, it will search only one entry in the
        symbol table to find A, two entries to find B and three entries to find C, etc.
    4.  Use NEXT statements without the index variable.  NEXT is somewhat faster than
        NEXT I because no check is made to see whether the variable specified in the NEXT
        is the same as the variable in the most recent FOR statement.
D  CONVERTING BASIC PROGRAMS NOT WRITTEN FOR AIM 65 BASIC
Though implementations of BASIC on different computers are in many ways similar, there are some
incompatibilities which you should watch for if you are planning to convert some BASIC programs
that were not written in AIM 65 BASIC.
    1.  Matrix subscripts.  Some BASICs use "[" and "]" to denote matrix subscripts.  AIM 65
        BASIC uses "(" and ")".
    2.  Strings.  A number of BASICs force you to dimension (declare) the length of strings
        before you use them.  You should remove all dimension statements of this type from
        the program.  In some of these BASICs, a declaration of the form DIM A$(I,J) declares
        a string matrix of J elements each of which has a length I.  Convert DIM statements of
        this type to equivalent ones in AIM 65 BASIC:  DIM A$(J).
        AIM 65 BASIC uses "+" for string concatenation, not "," or "&".
        AIM 65 BASIC uses LEFT$, RIGHT$ and MID$ to take substrings of strings.  Other
        BASICs uses A$(I) to access the Ith character of the string A$, and A$(I,J) to take a
        substring of A$ from character position I to character position J.  Convert as follows:
            OLD                 AIM 65
            A$(I)               MID$(A$,I,1)
            A$(I,J)             MID$(A$,I,J-I+1)
        This assumes that the reference to a substring of A$ is in an expression or is on the
        right side of an assignment.  If the reference to A$ is on the left hand side of an
        assignment, and X$ is the string expression used to replace characters in A$, convert
        as follows:
            OLD                 AIM 65
            A$(I)=X$            A$=LEFT$(A$,I-1)+X$+MID$(A$,I+1)
            A$(I,J)=X$          A$=LEFT$(A$,I-1)+X$+MID$(A$,J+1)
    3.  Multiple assignments.  Some BASICs allow statements of the form:  500 LET B=C=0.
        This statement would set the variables B & C to zero.
        In AIM 65 BASIC this has an entirely different effect.  All the "='s" to the right of the
        first one would be interpreted as logical comparison operators.  This would set the
        variable B to -1 if C equaled 0.  If C did not equal 0, B would be set to 0.  The easiest
        way to convert statements like this one is to rewrite them as follows:
            500 C=0:B=C
    4.  Some BASICs use "/" instead of ":" to delimit multiple statements per line.  Change all
        occurrences of "/" to ":" in the program.