guitarguy1685 Posted September 1, 2017 Posted September 1, 2017 I'm working on a lisp that that would have some options. I'd like the user to either start picking points or enter a keyword to access other options. So I need to get a point or string. for this I found I could use initget bit code 128 along with "getpoint". The user can pick a point or enter a keyword. Unfortunately, the user can also enter any other string. So then I thought, maybe I could use "While" and a Not/OR statement to filter out wrong values. The Not/Or evaluates to nil in the console so I'm not sure why it won't break the loop. Also when getting back to the loop I"m only allowed to enter a point. The INITGET is no longer valid. I tried grouping that into the WHILE statement that made things worse. I'm not that strong with loops so I may be approaching this all wrong. (defun C:test (/ ans ) (initget 128 "Rectangular Polygonal reV") (while (setq Ans (getpoint (strcat "\nSpecify first corner point or [Rectangular/Polygonal/reV]: "))) (not (or (= ans "Rectangular") (= ans "Polygonal") (= ans "reV") (= ans "") (= (type Ans) 'LIST) ) ) ) (princ (strcat "\n" ans)) (princ) );end defun Quote
guitarguy1685 Posted September 1, 2017 Author Posted September 1, 2017 I think I know what I did wrong. I'll check later Quote
hanhphuc Posted September 1, 2017 Posted September 1, 2017 alert output example ((lambda (/ p $ ret) ([color="blue"]while[/color] (not p) (initget 1 "Rectangular Polygonal reV") (setq p (getpoint (strcat "\nSpecify first corner point or [Rectangular/Polygonal/reV]: "))) (cond ((vl-consp p) (setq ret (cons (cond ($) ("Rectangular") ) (mapcar 'rtos p) ) ) ) ((vl-some ''((x) (= p x)) '("Rectangular" "Polygonal" "reV")) (princ (strcat "\nYou have choosen "p" ? " )) (setq $ p p nil ) ) ) ) (alert (apply 'strcat (mapcar ''((a b) (strcat a b)) '("TYPE: " " X= " " Y= " " Z= ") ret)) ) ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.