FOR loop
In KISSsoft you can also use FOR loops in the report generator. Within a FOR loop a numerical variable will be incremented (or decremented). You can use constructs that are nested down to 10 levels.
This loop is specified as follows:
FOR varname=%i TO %i BY %i DO {startwert}{endwert} {schritt}
// access variable with #varname or $varname
...
END FOR;
- Instead of %i or %f you can also use fixed figures (static FOR loop):
FOR varname=0 TO 10 BY 1 DO
...
END FOR; - or a mixture:
FOR varname=5 TO %i BY -1 DO {endwert}
...
END FOR; - Each FOR loop must end with the statement END FOR; (including semicolon). Each defined numerical variable (varname) within the loop can be addressed with the statement #varname.
- The increment can also be selected as a negative value (for example -1). However, it must never be 0. You must always specify the intervals.
- The #varname statement can be used for defining a variable. For example:
- Number of teeth: %3.2f {ZR[#varname].z}
- The $varname statement can be used for outputting the variable value as a letter. The value 0 corresponds to A, 1 corresponds to B etc. For example:
FOR quer=0 TO 3 BY 1 DO
Cross section $quer-$quer : %8.2f {Qu[#quer].sStatisch}
END FOR;
EXAMPLE OF A SIMPLE LOOP
FOR i=0 TO 10 BY 1 DO
Run number #i $i
END FOR;
Results in the following output:
Run number 0 A
Run number 1 B
Run number 2 C
Run number 3 D
Run number 4 E
Run number 5 F
Run number 6 G
Run number 7 H
Run number 8 I
Run number 9 j
Run number 10 K
The numerical variable can be used anywhere within the loop, even for arrays.