BIGAL Posted October 18, 2019 Posted October 18, 2019 (edited) Hi Guys I read a post on another site and thought should be able to do this to have multiple radio buttons and pick multiple buttons. I understand radio buttons toggle. But I would have thought if they are in individual boxes in some way would react just that way individually. The idea was to take the library multi input and add multi buttons. I have tried multi combos with not to much success at times button variable is changed but then not. The sample code will make a dcl just swap back to temp directory and un-remark delete file at end for testing looked at dcl to check bracket counts. The code should return RBx is 1 or 0 I am sure just overlooking something. Any help would be appreciated. See Below Edited October 19, 2019 by BIGAL Quote
Roy_043 Posted October 18, 2019 Posted October 18, 2019 Do you really want radio buttons to behave as toggles? From the point of GUI design this would be a very bad idea IMO. Quote
rlx Posted October 18, 2019 Posted October 18, 2019 Think you will need toggles for this one Bigal. Radio buttons only make sense if there are at least 2 in a radio_row or a radio_column. Only way to accomplish what you want (if I understand it right) would be to make toggles aware of each other by what I call the toggle police. Call with each toggle action the same sub function where you can decide if toggle A = on ("1") , then toggle B and C must be switched off ("0") 1 Quote
BIGAL Posted October 18, 2019 Author Posted October 18, 2019 (edited) Thanks guys will have another play. Using my multi getvals.lsp shrinking box size and put anything in a edit box does work was just trying to make picking easier. May look at greying edit box. (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "Tick items" "Blocks" 2 1 "" "Line" 2 1 "" "Circles" 2 1 "" "Plines" 2 1 ""))) Edited October 18, 2019 by BIGAL Quote
rlx Posted October 18, 2019 Posted October 18, 2019 while back I was working on my batch app and wanted to be able to select just a few strings. Could of course use toggles but just for fun wanted to make something different. It is only ment for a short list with short strings ; multiple from list (setq inp (mfl '("A" "B" "C" "D") '("A" "B"))) (defun mfl (%l %df / toggle l f p d r) (setq l (mapcar '(lambda (x)(if (member x %df)(strcat "[X] " x)(strcat "[O] " x))) %l)) (defun toggle (v / s r) (if (eq (substr (setq r (nth (atoi v) l)) 2 1) "X") (setq s "[O] ") (setq s "[X] ")) (setq l (subst (strcat s (substr r 5)) r l))(start_list "lb")(mapcar 'add_list l)(end_list)) (and (setq p (open (setq f (vl-filename-mktemp ".dcl")) "w")) (princ "cfl:dialog{label=\"Choose\";:list_box {key=\"lb\";} ok_cancel;}" p) (not (setq p (close p)))(< 0 (setq d (load_dialog f)))(new_dialog "cfl" d) (progn (start_list "lb")(mapcar 'add_list l)(end_list) (action_tile "lb" "(toggle $value)") (action_tile "accept" "(setq r (get_tile \"lb\"))(done_dialog 1)") (action_tile "cancel" "(setq r nil)(done_dialog 0)") (start_dialog)(unload_dialog d)(vl-file-delete f))) (mapcar '(lambda (y)(substr y 5)) (vl-remove-if '(lambda (x)(eq (substr x 2 1) "O")) l)) ) Quote
BIGAL Posted October 19, 2019 Author Posted October 19, 2019 (edited) Thanks rlx, I will probably go down the toggles path as the dcl can be done dynamically in terms of how many toggles. This is the 3rd in the library series and can have as many toggles as required the selection is returned as a list. Please feel free to use. Multiple toggles.lsp Edited October 19, 2019 by BIGAL Quote
hanhphuc Posted October 23, 2019 Posted October 23, 2019 @BIGAL toggle with checkbox output can be stored as bit is much convenient, like sysvar example (setvar 'osmode 24) etc.. (defun bits->fix ( l / e ans ) (setq e 0 ans 0) (repeat (length l ) (if (= (nth e (reverse l) ) 1 ) (setq ans (+ (expt 2 e) ans)) ) (setq e (1+ e)) ans ) ) ;(bits->fix '(1 1 1 1 1 0 1 0 0 0) ) 1000 (setq ans (ah:toggs '("Choose a number" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"))) ("1" "1" "0" "0" "1" "0" "0" "1" "1" "1") ; long output (setq toggs (bits->fix (mapcar 'atoi (reverse ans)) ) 915 suggestion: (mycheckbox strlst toggs) 1 Quote
BIGAL Posted October 23, 2019 Author Posted October 23, 2019 (edited) Not quite sure how I would use compared. (if ( = (nth 1 ans) "1")(do something1)) (if ( = (nth 2 ans) "1")(do something2)) …. (if ( = (nth 9 ans) "1")(do something10)) This would allow 10 different options to be ran 1 after another. I should have posted original post request which is on another forum. like a Audit then purge and purge again then saveas and close. Edited October 23, 2019 by BIGAL Quote
BIGAL Posted October 27, 2019 Author Posted October 27, 2019 (edited) Well had another go at a further library routine, why not a image as well as input boxes so describing what is required. To run just edit last line so it can find the sld, you can try your own the siz makes the image bigger or smaller. Change list to your input. Normally run with out last line just use the if not to load as a library routine. example at top. Will look into vector image should improve quality ps took 2 days to work out "Label" does not work must be lower case, such a simple mistake. Multi GETVALS Img.lsp Furntable.sld Edited October 27, 2019 by BIGAL Quote
dlanorh Posted October 28, 2019 Posted October 28, 2019 On 23/10/2019 at 05:04, BIGAL said: Not quite sure how I would use compared. (if ( = (nth 1 ans) "1")(do something1)) (if ( = (nth 2 ans) "1")(do something2)) …. (if ( = (nth 9 ans) "1")(do something10)) This would allow 10 different options to be ran 1 after another. I should have posted original post request which is on another forum. like a Audit then purge and purge again then saveas and close. Using a slightly modified version of @hanhphuc code above (moved the return outside the loop) you could (defun bits->fix ( lst / e ans ) (setq e 0 ans 0) (repeat (length lst) (if (= (nth e (reverse lst) ) 1) (setq ans (+ (expt 2 e) ans)) );end_if (setq e (1+ e)) );end_repeat ans );end_defun ;Then process (if (= (logand ans 1) 1)(do something1)) (if (= (logand ans 2) 2)(do something2)) (if (= (logand ans 4) 4)(do something3)) (if (= (logand ans 8) 8)(do something4)) (if (= (logand ans 16) 16)(do something5)) (if (= (logand ans 32) 32)(do something6)) (if (= (logand ans 64) 64)(do something7)) (if (= (logand ans 128) 128)(do something8)) (if (= (logand ans 256) 256)(do something9)) (if (= (logand ans 512) 512)(do something10)) Quote
BIGAL Posted October 28, 2019 Author Posted October 28, 2019 Understand now I think though for the more average lisp user the If = nth is easier to understand what is going on. In a complex lisp using the single value is a good idea rather than the original post request which was about cleaning up a dwg and doing a sequence of steps. 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.