while

AutoCad AutoLISP Functions

 
while
 
 
 

Evaluates a test expression, and if it is not nil, evaluates other expressions; repeats this process until the test expression evaluates to nil

(while testexpr [expr...]) 

The while function continues until testexpr is nil.

Arguments

testexpr

The expression containing the test condition.

expr

One or more expressions to be evaluated until testexpr is nil.

Return Values

The most recent value of the last expr.

Examples

The following code calls user function some-func ten times, with test set to 1 through 10. It then returns 11, which is the value of the last expression evaluated:

(setq test 1)
(while (<= test 10)
  (some-func test)
  (setq test (1+ test))
)