INPUT /  OUTPUT /  LANGUAGE





do field

Code field

Code carried out on each repetition of a for loop.

Applies to...

The for tag.

Sample usage

Behaviour

The code is carried out once for each value of the loop's count, with the for tag's name standing for the current count. Whatever the code generates each time is generated by the for tag, in order.

The code can generate values and carry out actions, but it cannot create presentation tags. To create several tag instances from one definition, use an array.

Example

Builds the first numbers of the Fibonacci sequence, by pushing the sum of the last two elements onto the end of a vector each time round the loop:

<fib:vector 1, 1>
<i:for 1 limit=5 do=<fib.push | add <fib.@ -1>, <fib.@ -2>>>
Fibonacci sequence: <join fib delim={, }>
Fibonacci sequence: 1, 1, 2, 3, 5, 8, 13

See also