; Multi ah:button Dialog box for 2 columns choice replacement of initget ; By Alan H Feb 2021 info@alanh.com.au ; It will remember what ah:button ws pressed if ran again with same request. ; (if (not ah:buttscol)(load "Multi radio buttons 2col.lsp")); loads the program if not loaded already ; (if (not ah:but)(setq ah:but 1))(if (not ah:but2)(setq ah:but2 1)) ; this is needed to set default ah:button ; you can reset default ah:button to user pick ; just use "but" value and compare to a list ; if you want a number use (atof (nth ah:but ah:butlst) or (atoi (nth ah:but2 ah:butlst2) ;(if (not ah:buttscol)(load "Multi Radio buttons 2col.lsp")) ;(if (= ah:but nil)(setq ah:but 1)) ;(if (= ah:but2 nil)(setq ah:but2 1)) ;(setq lst1 (list "Select type " "Existing" "Proposed"))) ;(setq lst2 (list "Select Road type" "Adoptable" "Private" "Highways")) ;(ah:buttscol ah:but ah:but2 "Please Select" lst1 lst2) ;(if (= ah:2col nil)(setq ah:2col 1)) ;(if (= ah:2col2 nil)(setq ah:2col2 1)) ;(setq lst1 (list "Select number" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10")) ;(setq lst2 (list "Select Char" "A" "B" "C" "D")) ;(ah:buttscol ah:2col ah:2col2 "Please choose" lst1 lst2) ;(setq ans1 (nth ah:2col lst1)) ;(setq ans2 (nth ah:2col2 lst2)) ;(ah:buttscol ah:but ah:but2 "please choose" '("Yes or No" "Yes" "No") '("up" "down") ) (defun col1 ( / l) (setq x 1) (repeat (length ah:butlst) (setq l (strcat "1Rb" (rtos x 2 0))) (if (= (get_tile l) "1" ) (setq ah:col1 x) ) (setq x (+ x 1)) ) (princ) ) (defun col2 ( / j ) (setq x 1) (repeat (length ah:butlst2) (setq j (strcat "2Rb" (rtos x 2 0))) (if (= (get_tile j) "1" ) (setq ah:col2 x) ) (setq x (+ x 1)) ) (princ) ) (defun ah:buttscol (ahdef1 ahdef2 toplabel ah:butlst ah:butlst2 / fo fname x k ) (setq len1 (length ah:butlst) len2 (length ah:butlst2)) (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) (write-line "AHbuttscol : dialog {" fo) (write-line (strcat " label = " (chr 34) toplabel (chr 34) ";" ) fo) (write-line " : row {" fo) (write-line " : boxed_radio_column {" fo) (write-line (strcat " width = 24 ;") fo) (setq x 1) (write-line (strcat " label = " (chr 34) (nth 0 ah:butlst) (chr 34) " ;" )fo) (write-line "spacer_1 ;" fo) (repeat (- (length ah:butlst) 1) (write-line " : radio_button {" fo) (write-line (strcat "key = " (chr 34) "1Rb" (rtos x 2 0) (chr 34) ";") fo) (write-line (strcat "label = " (chr 34) (nth x ah:butlst) (chr 34) ";") fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (setq x (+ x 1)) ) (if (< len1 len2) (repeat (- len2 len1) (write-line "spacer_1 ;" fo) ) ) (write-line " }" fo) (write-line " : boxed_radio_column {" fo) (write-line (strcat " width = 24 ;") fo) (setq x 1) (write-line (strcat " label = " (chr 34) (nth 0 ah:butlst2) (chr 34) " ;" )fo) (write-line "spacer_1 ;" fo) (repeat (- (length ah:butlst2) 1) (write-line " : radio_button {" fo) (write-line (strcat "key = " (chr 34) "2Rb" (rtos x 2 0) (chr 34) ";") fo) (write-line (strcat "label = " (chr 34) (nth x ah:butlst2) (chr 34) ";") fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (setq x (+ x 1)) ) (if (< len2 len1) (repeat (- len1 len2) (write-line "spacer_1 ;" fo) ) ) (write-line " }" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " ok_cancel ;" fo) (write-line " }" fo) (close fo) (setq ah:2col nil ah:2col2 nil) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "AHbuttscol" dcl_id) ) (exit) ) (setq x 1) (repeat (- (length ah:butlst) 1) (setq k (strcat "1Rb" (rtos x 2 0))) (action_tile k (strcat "(setq ah:2col " (rtos x 2 0) ")" )) (if (= ahdef1 x)(set_tile k "1")) (setq x (+ x 1)) ) (setq x 1) (repeat (- (length ah:butlst2)1) (setq k (strcat "2Rb" (rtos x 2 0))) (action_tile k (strcat "(setq ah:2col2 " (rtos x 2 0) ")" )) (if (= ahdef2 x)(set_tile k "1")) (setq x (+ x 1)) ) (action_tile "accept" "(if (= ah:2col nil) (setq ah:2col 1)(col1)) (if (= ah:2col2 nil) (setq ah:2col2 1)(col2))(done_dialog)") (action_tile "cancel" "(done_dialog) (exit)") (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (princ) ) ; end defun