7.67.52015-05-06

For… EndFor (procedure)

This command structure allows a series of nested commands to be repeated a specified number of times. Each for statement must have a corresponding endfor statement in order for PlanetPress Talk to know which commands to include in the loop. Note that you cannot increment the counter for a for() loop, inside the loop.

If you open a document created a with a version of PlanetPress earlier than 5.2.0, and if that document includes a for() loop with an increment greater than 1, you will notice that the loop is executed one less time than with your older version software both in PlanetPress itself and when you use the Optimized PostScript Stream option. The behavior on printers (using the Printer Centric option), on the other hand, remains unchanged.

Syntax

for( varname, startvalue, increment, stopvalue )

endfor()

Arguments

varname

Name of the variable to use for iterations. The variable must already exist.

startvalue

Integer value to initialize varname.

increment

Integer value used to increment varname after each iteration.

stopvalue

Integer value after which iterations stop.

Code Sample Example

This example simply prints 5 lines of text.

To cycle backwards through values, make startvalue larger than stopvalue, and specify a negative increment.

Example


define(&x,integer,1)
for(&x,1,1,5)
  show('Line nº '+inttostr(&x))
  crlf()
endfor()