I have learnt so many things from this forum and especially gurus like Lee Mac, CAB, Kerry, Fixo (I miss him), RibarM, Gile, YMG and so many others.
I have made a LISP for showing a Dialog Box within lisp (No seperate DCL File Needed) having Radio Buttons which returns the selected value. I learnt this from Lee Mac's code at :
http://www.theswamp.org/index.php?topic=49169.0Thanks to all forum members who helped me to be what I am today.
;; Makes temp DCL FIle with Radio Buttons and returns selected value (only 1 value can be selected)
(defun MM:RadioButtons (dlglbl rclbl lst defval / file tmp dcl_id dcl des return selval cntxx)
;; Inspired from Lee Mac - my mentor for AutoLISP, http://www.theswamp.org/index.php?topic=49169.0
;; INPUT VALUES :
;; ------------
;; dlglbl = Dialog Box Label
;; rclbl = Boxed Radio Column Label
;; lst = List containing labels of Value of each Radio Button (dynamic number of items possible)
;; defval = Default Value will be Highlighted while loading Dialog Box
;; RETURN VALUE :
;; ------------
;; If nothing is selected, then NIL, otherwise returns selected option.
(defun *error* (msg)
(if (and (= 'int (type dcl_id)) (< 0 dcl_id))
(unload_dialog dcl_id)
)
(if (= 'file (type des))
(close des)
)
(if (and (= 'str (type dcl)) (setq dcl (findfile dcl)))
(vl-file-delete dcl)
)
(if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
(princ (strcat "\nError: " msg))
)
(princ)
)
(defun saveVars ()
(if (not selval)
(setq selval defval)
)
)
(setq dcl (vl-filename-mktemp "tmp.dcl"))
(setq des (open dcl "w"))
(write-line
(strcat "RBBox : dialog { //dialog name
label = \"" dlglbl
"\" ; //give it a label
:boxed_radio_column { //define radio column
label = \"" rclbl
"\" ; //give it a label"
)
des
)
(setq cntxx 0)
(foreach xx lst
(setq cntxx (1+ cntxx))
(write-line
(strcat ": radio_button { //define radion button
key = \""
(strcat "rb" (itoa cntxx))
"\" ; //give it a name
label = \""
xx
"\" ; //give it a label"
(if (equal (strcase defval) (strcase xx))
"\nvalue = \"1\" ; //switch it on"
"\nvalue = \"0\" ; //switch it off"
)
"\n} //end definition"
)
des
)
)
(write-line
(strcat
"} //end radio column
ok_cancel ; //predifined OK/Cancel
: row { //define row
: paragraph { //define paragraph
: text_part { //define text
label = \"Text Label. \"; //give it some text
} //end text
} //end paragraph
} //end row
}"
)
des
)
(not (setq des (close des)))
(< 0 (setq dcl_id (load_dialog dcl)))
(new_dialog "RBBox" dcl_id)
(setq cntxx 0)
(foreach xx lst
(setq cntxx (1+ cntxx))
(action_tile (strcat "rb" (itoa cntxx)) (strcat "(setq selval \"" xx "\")"))
)
(action_tile "accept" "(saveVars)(done_dialog 2)")
(action_tile "cancel" "(done_dialog 1)(setq selval nil)")
(start_dialog)
(unload_dialog dcl_id)
(if (setq dcl (findfile dcl))
(progn (vl-file-delete dcl))
)
selval
)
Testing Function :
(defun c:test (/ RBSEL)
(vl-load-com)
(if (setq rbsel (MM:RadioButtons "Select a Value" "Values" (list "1" "2" "3" "4" "5" "6") "3"))
(alert (strcat "Selected Value is : " rbsel))
(alert "Nothing Selected.")
)
(princ)
)