With much reading and practice I have become a bit familiar with writing
autolisp routines. Things I couln't do a year ago are now becoming quite
One thing, however I'm having trouble with is using "while" for loops. Can
anyone explain the "while" function and how it works, maybe with a couple of
I'm especially baffled by how it is used to read down a data list, looking
for info. Any help would be appreciated.
Reply to
Loading thread data ...
(while (some condition exists) (do this) (and do this) (and this...) );; end while
"Some condition" can be T or nil, an equality, or whatever. For example:
(setq counter 10) (while (> counter 0) (princ (strcat "\n" (atoi counter))) (setq counter (1- counter)) );; while (princ)
As for your "data list" if it's in the form of a LISP list, you can use the counter variable to get the "nth" element of the list, as in (setq dat (nth datalist counter)) and so on.
If you're reading data from a file, all you have to do is to verify that there's another element available:
(while (setq dat (read-line infile)) (do things) (do more stuff) )
(read-line ...) returns nil after it passes the last element of the file, exiting the loop. ___
Reply to
Paul Turvill
Thanks Paul. That was very simple yet concise. It will help a great deal. Thanks again.
Reply to

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.