Chapter 14. Statement Reference
212
Syntax:
FOR controlvariable = initialvalue TO finalvalue [STEP
increment]
.
.
.
NEXT [controlvariable]
Parameter:
controlvariable
A non-array numeric variable.
initialvalue, finalvalue,
and
increment
Numeric expressions.
Description:
FOR
…
NEXT
defines a loop containing statements (which is called "body of a loop")
to be executed by the number of repetitions controlled by
initialvalue
,
finalvalue
, and
increment
.
■
Processing procedures
(1) The Interpreter assigns
initialvalue
to
controlvariable
.
(2) The Interpreter checks terminating condition; that is, it compares the value of
controlvariable
against the
finalvalue
.
- When the value of
increment
is positive:
If the value of
controlvariable
is equal to or less than the
final-
value
, go to step (3). If it becomes greater the
finalvalue
, the program
proceeds with the first line after the
NEXT
statement (the loop is over).
- When the value of
increment
is negative:
If the value of
controlvariable
is equal to or greater than the
final-
value
, go to step (3). If it becomes less than the
finalvalue,
the pro-
gram proceeds with the first line after the
NEXT
statement (the loop is over).
(3) The body of the loop executes and the
NEXT
statement increases the value of
controlvariable
by the value of
increment
. Then, control returns to
the
FOR
statement at the top of the loop. Go back to step (2).
Flow control statement
FOR...NEXT
Defines a loop containing statements to be executed a specified number of times.
Summary of Contents for BHT-BASIC 100 SERIES
Page 1: ......
Page 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Page 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Page 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Page 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...