$loop

The $loop variable is set at the start of every iteration (and at the non-BREAK end) of looping statements, e.g. LOOP, SQL, TIMPORT, etc. Inside the loop, it is the iteration count (counting from 0); at the end of the loop, it is thus the number of iterations. In version 8.00.1645136290 20220217 and later, $loop is also set at the end of self-closing optional-looping statements, just as if the statement was looping.

Note that for LOOP statements, $loop also includes the initial SKIP value; this is not true for other looping statements. Note also that for WHILE statements, $loop is set before the WHILE condition is evaluated, so that $loop may be used as a iterator in the condition.

Note that in version 8 and later syntax (syntaxversion pragma, here), the $ret.code variable is often a more reliable way of checking success/failure of a <sql> statement than checking $loop, as the latter can be 0 for a zero-result-row successful statement as well as a failed (no rows matched) statement.


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.