MetroCad USA

LOOP Functions


(REPEAT <int> .............<expressions>.......... )

Repeats the <expressions> the number of times specified by <int>. (repeat 4 (command "circle" pause 1.0) ) This would draw four 1.0 radius circles.


(WHILE <test-expr> ..........<expressions>......... )

Repeats the <expressions> until the condition in <test-expr> is true. <test-expr> is a conditional statement (= 1 1), (> 2 1), (< 4 10) are all true conditions. (while (< a b) (setq a (+ a 1)) )


(FOREACH <item-sym> <list> ..........<expressions>......... )

Temporarily holds each element in <list> in a local variable <item-sym> and performs <expressions> on each item in the list. (foreach num (1 3 6 10 40 50) (setq a (* 2 num)) (print a) ) This would multiple each number 1, 3, 6, 10, 40, and 50 by 2 and print the numbers on the command line. 2 6 12 20 80 100





Example functions page
Back Home