Kowal Posted February 2, 2018 Posted February 2, 2018 (getstring (strcat "<" "Test" ">")) Works like in the picture. Is it possible to do not print the default value? Just like the picture below. Quote
Aftertouch Posted February 2, 2018 Posted February 2, 2018 Your looking for this? (setq thestring (getstring "\nEnter string <TEST>: ")) (if (null thestring)(setq thestring "TEST")) When there is no imput, the value is set to "TEST". this part: (getstring "\nEnter string <TEST>: ") is just cosmetic, and could also be: (getstring "\nEnter string: ") Quote
Kowal Posted February 2, 2018 Author Posted February 2, 2018 I have a variable string: (setq a "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz") I want to modify it using the function getstring (getstring (strcat "<" a ">")) That is now: I want to have it without a prefix. Is it possible? Quote
Roy_043 Posted February 2, 2018 Posted February 2, 2018 @Kowal: If you don't want this prompt why are you providing it? Quote
ronjonp Posted February 2, 2018 Posted February 2, 2018 If I'm understanding you correctly, you're just missing the brackets: (getstring (strcat "[]")) Quote
Grrr Posted February 2, 2018 Posted February 2, 2018 If I'm understanding you correctly, you're just missing the brackets: (getstring (strcat "[]")) Nice Ron, this is new for me! Perhaps to make an useful prompt from this would be: (cond ((= (setq v (getstring (strcat "[<" a ">]"))) "") a)(v)) Quote
ronjonp Posted February 2, 2018 Posted February 2, 2018 Nice Ron, this is new for me!Perhaps to make an useful prompt from this would be: (cond ((= (setq v (getstring (strcat "[<" a ">]"))) "") a)(v)) Definitely I use something like this a lot for getkword: (or *default* (setq *default* "Width")) (initget (setq options "Arc Length Width")) (setq *default* (cond ((getkword (strcat "\nPick an option: [" (vl-string-translate " " "/" options) "] <" *default* ">:" ) ) ) (*default*) ) ) Quote
Kowal Posted February 2, 2018 Author Posted February 2, 2018 Thank you ronjonp. I was looking for such a solution. Quote
BIGAL Posted February 2, 2018 Posted February 2, 2018 Ronjonp are we missing a defun ? Just got the normal input on command line. My $0.05 with multiple key words can use a dcl list box method and pick only one. Need a library routine routine for the dcl but basicly 3 lines of code. Thanks to lee for listbox. (if (not LM:listbox)(load "ListBoxV1-2.lsp")) ; loads the lisp if not already loaded (setq lst (list "Stone" "Ceramic" "Plastic")) (setq ans (nth 0 (LM:listbox "Pick material" lst 1))) ; calls the list box and return item Quote
ronjonp Posted February 3, 2018 Posted February 3, 2018 Ronjonp are we missing a defun ? Just got the normal input on command line. My $0.05 with multiple key words can use a dcl list box method and pick only one. Need a library routine routine for the dcl but basicly 3 lines of code. Thanks to lee for listbox. (if (not LM:listbox)(load "ListBoxV1-2.lsp")) ; loads the lisp if not already loaded (setq lst (list "Stone" "Ceramic" "Plastic")) (setq ans (nth 0 (LM:listbox "Pick material" lst 1))) ; calls the list box and return item Not missing a defun just a simple example. You'll need to set dynmode to 1 to get the result at the cursor. Quote
BIGAL Posted February 3, 2018 Posted February 3, 2018 (edited) Thanks thought it would be a switch somewhere as you know there are so many. Need Dynprompt = 1 also. I work with the dynamics turned off a personal preference. Ronjonp I like the idea so made it a library function, will probably use in future as I am moving my code away from command line input to a more in your face approach. ; get keyword on screen input by Ronjonp Jan 2018 ;http://www.cadtutor.net/forum/showthread.php?102708-Getstring-a-default-value-without-print. ; modified by BIGAL Jan 2018 as a library function (defun keyword (*default* options / ) (setq olddynmode (getvar "dynmode")) (setq olddynprompt (getvar "dynprompt")) (setvar "dynmode" 1) (setvar "dynprompt" 1) (initget options ) (setq *default* (cond ((getkword (strcat "\nPick an option: [" (vl-string-translate " " "/" options) "] <" *default* ">:" ) ) ) (*default*) ) ) (setvar "dynmode" olddynmode) (setvar "dynprompt" olddynprompt) ) ; example (keyword "Width" "Length Height Width") Edited February 3, 2018 by BIGAL Quote
ronjonp Posted February 4, 2018 Posted February 4, 2018 Glad you could use it . I generally draft with the dynmode set to 0 as well for performance. IMO .. I'd put an error function in that if you're changing variables within the function. Quote
BIGAL Posted February 4, 2018 Posted February 4, 2018 ronjonp good idea I have been meaning to write a bit of a reset lots error function as a library function, often need filedia reset. Quote
ronjonp Posted February 5, 2018 Posted February 5, 2018 Maybe something like this so you don't have a common global which might cause problems. (defun keyword (key options default / *error* def vars) (defun *error* (msg) (mapcar '(lambda (x) (setvar (car x) (cdr x))) vars) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)) ) (princ) ) (or (setq def (getenv key)) (setq def default)) (setq vars (mapcar '(lambda (x) (cons x (getvar x))) (list 'dynmode 'dynprompt))) (mapcar '(lambda (a b) (setvar (car a) b)) vars '(1 1)) (initget options) (setq def (cond ((getkword (strcat "\nPick an option: [" (vl-string-translate " " "/" options) "] <" def ">:") ) ) (def) ) ) (mapcar '(lambda (x) (setvar (car x) (cdr x))) vars) (setenv key def) ) (keyword "MyProgram" "Length Height Width Depth" "Height") 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.