AutoCAD: Secrets Every User Should Know

WHILE Function

To use the REPEAT function, you have to know how many times you want the group of functions to be repeated. In contrast, the WHILE function repeats a series of functions until a specified condition is met. Let s use the WHILE function in the next example, which adds numbers in sequence to a drawing, beginning with whatever value is indicated by the operator. As long as the operator keeps picking points, the program keeps placing numbers. When the operator terminates the program with an Enter, the Spacebar, or a right-click with the mouse, the program exits the WHILE function. See Listing 9.9.

Listing 9.9
Number.lsp        (defun C:Number (/  txtStyle numSeq txtInsert str1 str2)          (setq txtStyle (getvar "textstyle"))          (command "STYLE" "romans0" "romans" 0 1 0 "N" "N" "N")          (setq numSeq (getint "\nFirst number in sequence <1>: "))          (if (= numSeq nil)(setq numSeq 1))          (setq txtInsert (getpoint "Insertion point:  "))          (while txtInsert            (setq str1 (itoa numSeq))            (setq str2 (strcat "#" str1))    ...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Teach Pendants
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.