Contents | Prev | Next | Index
The for statement indicates that a statement is to be repeatedly executed for a fixed number of times while a progression of values is assigned to a variable. This variable is called the control variable of the for statement, and it must be of a non-real basic type, of an enumeration, or of a subrange type.
for_stmt ::= FOR control_list DO
stmt control_list ::= control_assignment by_expr to_expr control_assignment ::= control_var := expr control_var ::= <identifier> to_expr ::= expr by_expr ::= TO ::= DOWNTO |
Both increasing or decreasing progression of values for the control variable are possible, depending on preceding the end value by a TO or DOWNTO keyword. Each iteration increases or decreases the control variable by 1.
Examples:
FOR i:=0 TO 79 DO
k := k+a[i];FOR i:=79 DOWNTO 1 DO
a[i] := a[i-1];
Contents | Prev | Next | Index
Canterbury Pascal for JVM (Last documentation update
Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com
. All rights reserved.
Please send any comments or corrections to
neuhoff@mhccorp.com