Jump to content

Recommended Posts

Posted

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

Posted

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)
)

Posted

Kerry,

 

that's a very quick response, thanks a lot.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...