spec

Software for Diffraction

2.3.15.3. - For Statement



The for statement comes in two forms. The first is
for ( expression1 ; expression2 ; expression3 ) statement
The flow expressed in this statement can be thought of as
expression1
while ( expression2 ) {
      statement
      expression3
}
Any of the expressions can be missing. A missing expression2 is equivalent to
while ( 1 )
The second form of the for statement concerns associative arrays. A syntactical feature for these arrays (forms of which are available in the standard awk and gawk utilities) is available in spec as of release 4.01.05. The construction
for ( identifier in assoc-array ) statement
will run through each element of the associative array assoc_array assigning to identifier the string value of the index of each element. Note, though, the order in which the elements are assigned should be considered arbitrary.

For two-dimensional associative arrays, the construction
for ( identifier in assoc-array[expr] ) statement
will step through each element of assoc-array having expr has the first index.