$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.

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 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 statement.


Copyright © Thunderstone Software     Last updated: Jul 17 2021
Copyright © 2021 Thunderstone Software LLC. All rights reserved.