Quote:surely it just loops back to the WHILE? |
|
It doesn't loop back to the WHILE - that would be inefficient. It loops back to the conditional expression in the WHILE statement (skipping the WHILE keyword entirely) and hence the evaluation of that conditional expression is counted by the profiler as part of the ENDWHILE statement.
Another way to look at it is to realise that if the initial condition is TRUE (i.e. the body of the loop is executed at least once) WHILE...ENDWHILE is executed by the interpreter exactly the same as REPEAT...UNTIL is: the conditional test is performed at the end of the loop, not at the beginning.
Effectively the code you listed is executed by the interpreter as if it was the following:
Code:
IF (this%<>0) AND (word$ > FNgetitem(index{}, this%)) THEN
REPEAT
prev% = this%
this% = index.link%
UNTIL NOT ((this%<>0) AND (word$ > FNgetitem(index{}, this%)))
ENDIF
Richard.