ODEY Posted May 11, 2010 Posted May 11, 2010 Hi, i just found out about auto lisp a month ago and got interested on it. so i'm really a novice when it comes to making lisp routine. recently, there was this "tip" on making a default value when making a routine and this serves as my pattern. but something is. wrong. it's keeping the string value only once, just to show what is the current value but when you press enter, it's no longer there when you repeat the command unlike in the case of integer, value remains there always. below is the routine sample.tnx code: (defun c:prog1 (/ a b) (if (= gv nil) (setq gv "NAME") );end if (princ "\Member <") (princ gv) (princ "> ") (setq a (strcase(getstring))) (if (= gv1 nil) (setq gv1 0) );end if (princ "\Quantity <") (princ gv1) (princ "> ") (setq b (getint)) (if (= b nil) (setq b gv1) );end if (setq gv a) (princ "\nThe Member is ") (princ a) (setq gv1 b) (princ "\nThe Quantity is ") (princ b) (princ) );defun Quote
Kerry Brown Posted May 11, 2010 Posted May 11, 2010 Perhaps try something like ; This need further enhancement to be production code, but will get you started in understanding the process. (defun c:prog1 (/ tmp) ;; set global variables (or gv (setq gv "NAME")) (or gv1 (setq gv1 0)) ;; (if (/= "" (setq tmp (strcase (getstring (strcat "\nMember <" gv "> "))))) (setq gv tmp) ) ;; (if (setq tmp (getint (strcat "\nQuantity <" (itoa gv1) "> "))) (setq gv1 tmp) ) ;; (princ "\nThe Member is ") (princ gv) (princ "\nThe Quantity is ") (princ (itoa gv1)) (princ) ) Quote
ODEY Posted May 11, 2010 Author Posted May 11, 2010 Kerry, that's a very quick response, thanks a lot. 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.