next up previous

12.6.8 Break

The break function immediately terminates the currently iterating while loop, progn exeexecution, or certain instance set query functions (do-for-instance, do-for-all-instances and delayed-do-for-all-instances).

The break function can only be used within the actions of a while loop, progn execution, or the specified instance set queries previously listed. Other uses will have no effect. The break cannot be used within a progn unless it is valid for the outer scope of the progn. In addition, break should not be used as an argument to another function call.

Syntax

(break)

Example

CLIPS>
(deffunction iterate (?num)
  (bind ?i 0)
  (while TRUE do
    (if (>= ?i ?num) then
       (break))
    (printout t ?i " ")
    (bind ?i (+ ?i 1)))
  (printout t crlf))
CLIPS> (iterate 1)
0
CLIPS> (iterate 10)
0 1 2 3 4 5 6 7 8 9
CLIPS>


next up previous