ODEY 发表于 2022-7-6 11:13:20

default values - help, somethi

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")   (setq a (strcase(getstring)))   (if (= gv1 nil)       (setq gv1 0)   );end if         (princ "\Quantity")   (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

Kerry Brown 发表于 2022-7-6 11:45:55

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")))))   (setq gv tmp) ) ;; (if (setq tmp (getint (strcat "\nQuantity")))   (setq gv1 tmp) ) ;; (princ "\nThe Member is ") (princ gv) (princ "\nThe Quantity is ") (princ (itoa gv1)) (princ))

ODEY 发表于 2022-7-6 12:19:11

Kerry,
 
that's a very quick response, thanks a lot.
页: [1]
查看完整版本: default values - help, somethi