BASIC FUNCTIONS
SECTION 5.7
5.7.3
Function FOR executes a series of instructions in a loop a given
number of times.
Syntax
FOR N A TO B STEP C
NF.XT N
Where N is a variable, A is a numeric start value, Bis a
numeric end value and C is an increment/decrement value.
A, Band C can be numbers, variables or expressions.
Examples 10 FOR A= 1 TO 100 STEP 10
100 NEXT A
causes the value of A to equal 1,11,21 etc., for each
execution of the loop.
To obtain a
decrementing count negative values of STEP are
used.
1000 FOR 21=91 TO 10 STEP
-.1
1050 NEXT 21
Remarlcs When followed by a NEXT statement, FOR will execute the
intervening parameters for the number of times indicated by
the values A and B divided by N to the formula:
(B-A+2)/N
When terminating FOR ... NEXT loops it is important to end
using NEXT and
not GOTO. Alternatively, exiting via a
RETURN when in a subroutine will not cause a build up of
the 'control stack'.
Failure to do this will result in a control stack error.
VER.V09F
PAGE 5 - 37