@Ranjit_Singh wrote:
You do not have any condition to exit the while loop. Also, initialize the count variable outside the while loop.
(setq coutn 1)
(while (<= count 25) ....do something........) ;I am using 25 just as an example
There's no need to limit it to any arbitrary number, which may be beyond however many you would ever do, but does still limit you to that many. Also, doing it that way requires ESCape to get out of it if you don't get as far as that many, and that means if you want the code to continue on to anything else after you've done all the Pline/Hyperlinking you want, that will be impossible, because the ESCape will cancel the whole routine. You can have it be contingent on the User supplying the numbers, and they can do as many as they like, and get out of it with Enter/space, which will allow the routine to continue on to other stuff if desired:
(defun C:Test (/ count Text1 Text2)
(setq count 1)
(while
(and
(setq Text1 (getint "\nEnter integer Text1 [<exit>]:")); returns nil on Enter and stops the (while) loop
(setq Text2 (getint "\nEnter integer Text2 :")); could also add the [<exit>] option in this line
); and
(command "_.pline")
(while (> (getvar 'cmdactive") 0) (command pause)); for User input until Pline command is ended, then:
(command "-HYPERLINK" "I" "O" "Last" "" count Text1 Text2 "")
(setq count (1+ count))
); while
;;;... do something else now, if you want, such as: (prompt (strcat "\n" (itoa count) Polylines Hyperlinked.")) ...
); defun
I added the word integer into the prompts to suit the (getint) function, but you could just as well word them differently, without the "Text" part in the prompt, so a User won't think they can enter "Marilyn Monroe" or something, e.g.:
....
(setq Text1 (getint "\nFirst number [<exit>]: ")); returns nil on Enter and stops the (while) loop
(setq Text2 (getint "\nSecond number: ")); could also add the [<exit>] option in this line
....
Kent Cooper, AIA