This could be described as the “Expert
System” way of finishing a loop. More generally we might have:

IF ?ITEM IN SET AND <intermediate code without ORs> AND <test on ?ITEM> AND <further code for successful ?ITEM>THEN <predicate ?ITEM> AND BREAK ?ITEM

This is very elegant. It loops through SET until it finds the item
where the test succeeds, executes the further code and then the
predicate, after which the loop is stopped by the BREAK. But it is
dangerous because it involves having the <test on ?ITEM> after
intermediate code. When this test fails it causes backtracking which
is only halted by the loop statement itself. So this technique is
really only usable if the intermediate code does not include any
tests which evaluate TRUE which have OR statements associated with
them.

Finding the Position of a Substring in a String

The following example shows how the “Expert System” approach
can be used to implement a standard problem, finding the position of
a substring in a string, or returning 0 if it cannot be found. In
this case we have a WHILE loop with two tests applied in succession.
The rule always reaches the predicate and ends TRUE. Note also the
dummy WHILE loop which is started when ?MAXLOOP is 0; this is
required in order to ensure that the BREAK ?ILOOP statement in the
conclusion will work in all cases.

/* Test whether found it: if so, will go forward to */ /* THEN clause and BREAK, proving rule with the */ /* correct ?IPOS */

AND ( ?STRIPOS EQ ?SUBSTR

/* Haven't found the substring; see whether finished */ /* looping. If we haven't, interpreter will backtrack */ /* to WHILE clause and then iterate forward again; */ /* if we have finished, set ?IPOS to 0 and go forward */ /* to the THEN clause and BREAK */