Ramana Posted February 4, 2010 Posted February 4, 2010 Hello Friends, Greetings, 1. i have started exploring DCL programing, I facing a problem with Radio buttons, I have designed a dialog box with 4 radio buttons to draw all commands, i have kept one radio button default by setting value of that radio button to 1. But there is no effect when i press ok. with out selecting any button assuming that default is on. 2.after selecting an option by selecting a radio button, if i click on Cancel button is also funtioning with the selected option with out canceling the command. Please guide me. code i have used:- command:dialog{ label = "COMMANDS"; :radio_row { label = "Draw Commands"; :radio_button { label="Line"; key = "lin"; } :radio_button { label="Circle"; key = "cir"; value = "1"; } :radio_button { label="Ellipse"; key = "eli"; } :radio_button { label="Arc"; key = "arc"; } :radio_button { label="Polygon"; key = "pol"; } } ok_cancel; } Lisp routine i have used:- (defun C:cmd() (setq dcl_id (load_dialog "cmd.dcl")) (if(not (new_dialog "command" dcl_id)) (exit) );if (action_tile "cancel" "(done_dialog) (setq userclick nil)") (action_tile "lin" "(setq cmd \"line\")") (action_tile "cir" "(setq cmd \"circle\")") (action_tile "eli" "(setq cmd \"ellipse\")") (action_tile "arc" "(setq cmd \"arc\")") (action_tile "pol" "(setq cmd \"polygon\")") (action_tile "accept" "(done_dialog)(setq userclick T)") (start_dialog) (unload_dialog dcl_id) (cond ((= cmd "line" ) (command cmd) ) ((= cmd "circle" ) (command cmd) ) ((= cmd "arc" ) (command cmd) ) ((= cmd "ellipse" ) (command cmd) ) ((= cmd "polygon" ) (command cmd) ) );cond );defun Thanks in advance. Ramana Quote
TimSpangler Posted February 4, 2010 Posted February 4, 2010 You'll need this code after the dialog loads, put this right before you action tile statements (if (not cmd) (setq cmd "circle") ) Quote
Ramana Posted February 5, 2010 Author Posted February 5, 2010 Hello friend, no postive result with this, i have tried with the above solution. Thanks for your assistance. Ramana Quote
Lee Mac Posted February 5, 2010 Posted February 5, 2010 Ramana, If the user does not click a radio button, the variable 'cmd' is nil. Therefore no COND statement is evaluated. Before your action_tile statements, place this piece of code: (set_tile "cir" "1") (setq cmd "circle") Also, I would recommend using "eq" when comparing strings, and also use strcase to avoid error. Quote
The Buzzard Posted February 6, 2010 Posted February 6, 2010 Hello friend, no postive result with this, i have tried with the above solution. Thanks for your assistance. Ramana Ramana, Try this: CMD.dcl cmd : dialog { label = "COMMANDS"; : column { : boxed_radio_column { label = "Draw Commands"; : radio_button { label = "Circle"; key = "circle"; } : radio_button { label = "Line"; key = "line"; } : radio_button { label = "Ellipse"; key = "ellipse"; } : radio_button { label="Arc"; key = "arc"; } : radio_button { label="Polygon"; key = "polygon"; } } } : row { : button { label = "&OK"; key = "accept"; fixed_width = true; is_default = true; } : button { label = "&Cancel"; key = "cancel"; fixed_width = true; is_cancel = true; } } } CMD.lsp (defun C:cmd(/ cmd) ;Defun, Declare local variables (or c:md$ (setq c:md$ "circle")) ;Set defaults (setq dcl_id (load_dialog "cmd.dcl")) ;Load dialog (if (not (new_dialog "cmd" dcl_id)) ;Check for dialog (exit)) ;If dialog not found, Exit (set_tile c:md$ "1") ;Set default radio button (action_tile "circle" "(setq c:md$ \"circle\")") ;When circle selected set c:md$ (action_tile "line" "(setq c:md$ \"line\")") ;When line selected set c:md$ (action_tile "ellipse" "(setq c:md$ \"ellipse\")") ;When ellipse selected set c:md$ (action_tile "arc" "(setq c:md$ \"arc\")") ;When arc selected set c:md$ (action_tile "polygon" "(setq c:md$ \"polygon\")") ;When polygon selected set c:md$ (action_tile "accept" "(done_dialog)(setq userclick T)") ;When OK button selected set userclick to true (action_tile "cancel" "(done_dialog)(setq userclick nil)") ;When Cancel button selected set userclick to nil (start_dialog)(unload_dialog dcl_id) ;Start dialog, Unload dialog (setq cmd c:md$) ;Set cmd from c:md$ value (if userclick ;If OK button selected (cond ;Condition ((= cmd "circle" ) (command cmd)) ;cmd = circle, Start circle command ((= cmd "line" ) (command cmd)) ;cmd = line, Start line command ((= cmd "arc" ) (command cmd)) ;cmd = arc, Start arc command ((= cmd "ellipse" )(command cmd)) ;cmd = ellipse, Start ellipse command ((= cmd "polygon" )(command cmd)) ;cmd = polygon, Start polygon command ) ;End condition ) ;End if (princ)) ;Exit quietly (princ "\nCMD.lsp loaded...Type CMD to start program") ;Print to command line Quote
Ramana Posted February 6, 2010 Author Posted February 6, 2010 Hai friend, this is working fine, thanks, but cancel button is failing to cancel the command with out doing any task. it is taking the selected option and performing the command. But thanks my default option is working well. Quote
Ramana Posted February 6, 2010 Author Posted February 6, 2010 Mr.Buzzard, Thanks for the code, this code is working well, i understood the concept of defining the default for Radio buttons & my cancel button is also working fine in the given code. Once again thanks for helping me. Ramana Quote
The Buzzard Posted February 6, 2010 Posted February 6, 2010 Mr.Buzzard, Thanks for the code, this code is working well, i understood the concept of defining the default for Radio buttons & my cancel button is also working fine in the given code. Once again thanks for helping me. Ramana Glad I could be of help. Quote
The Buzzard Posted February 6, 2010 Posted February 6, 2010 Ramana, I forgot to mention the reason you had a problem with the Cancel & Accept buttons was that you forgot the (if userclick The default settings were done as outlined by Tim and Lee Mac. Just wanted you to understand the problem. Also I made the radio buttons in a column instead of a row because they look much better this way. Also it pays to name your lisp code and dcl code the same so one would know they belong with each other. Sorry I forgot to mention all this. 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.