can't figure this out
I have this code(setq FPname (cond ((getstring (strcat "\nF-Part to insert : "))) (FPname)))In this code FPname is a global variable.This way it is remembered the next time I use this lisp.so it would work like this
1st time run
"f-Part to insert >: "i might enter 1234
2nd time run
"f-part to insert : "I just press enter
Right now if I press enter FPname goes to nill.This worked for me before in this lisp
(setq ANG_L2 (cond ((getdist (strcat "\nSpecify size of second leg : "))) (ANG_L2)))but it is just slightly different.In this one i was using integers and in the first one i'm using a string.any thoughts? You won't be able to use the same construct with getstring.
Whereas getint, getreal etc return nil on null input, getstring will return an empty string (i.e. non-nil). Something like would suffice:
(or *def* (setq *def* "Default"))(or (eq "" (setq tmp (getstring t (strcat "\nString: ")))) (setq *def* tmp))Or
(or *def* (setq *def* "Default"))(setq *def* (cond ((= "" (setq tmp (getstring (strcat "\nString: ")))) *def*) (tmp))) Maybe a little old fashion but I still prefer a more straight forward approach.
(setq def_input "Default") (while (or (not input) (not (snvalid input))) (setq input (getstring (strcat "\nString Input : "))) (cond ((= input "")(setq input def_input))))
This gives you unlimited( or ) and ( cond ) testing and is a bit more readable to me.My $0.02.-David
wow that makes total sense.thanks so much very interesting.so many ways to get the same result.I do appreciate your guys help. Is there a place to submit lisps on this site? i'd like to submit what I've done with this sites help.Maybe it can help others.
btw is there any purpose to using the asterisks around *def* ?I noticed it with some code I got from an error handler where they used *error*.
I use asterisks in Global variables just to make them "less common" to avoid clashes with other programs. In essence, a global variable could be named in the same fashion as a local one, but if two programs use the same global variable, there could be undesired consequences.
*error* is something completely different, it is AutoCAD's user-definable error handling function.
页:
[1]