slimpickinz Posted March 20, 2010 Share Posted March 20, 2010 Hey guys and gals... Been a while since I visited. I need some direction on how the toggle selections are done in the routine posted HERE. The Buzzard and CAB were a big help with the creation of this, so if you two could chime in, it would be quite helpful. Glad to be back! -SlimP Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted March 20, 2010 Share Posted March 20, 2010 Hey guys and gals...Been a while since I visited. I need some direction on how the toggle selections are done in the routine posted HERE. The Buzzard and CAB were a big help with the creation of this, so if you two could chime in, it would be quite helpful. Glad to be back! -SlimP Hey Slimp, Been a while. Below is a simple lisp with a Toggle defaulted to on. Just unclick or click the toggle and click OK to read the command prompt responce. Enjoy, The Buzzard Toggle.dcl MAIN : dialog { label = "Toggle"; : boxed_column { label = "Snap Angle"; : toggle { label = "On/Off"; key = "TOG1"; } } : boxed_column { label = "Control Buttons"; : button { label = "&Proceed"; key = "accept"; width = 18; fixed_width = true; alignment = right; is_default = true; } : button { label = "&Exit Program"; key = "cancel"; width = 18; fixed_width = true; alignment = right; is_cancel = true; } } } Toggle.lsp (defun C:TOGGLE (/ TOG1$) (or T:OG1$ (setq T:OG1$ "1")) (setq DCL_ID (load_dialog "TOGGLE.dcl")) (if (not (new_dialog "MAIN" DCL_ID)) (cond ((<= (setq DCL_ID (load_dialog "TOGGLE.dcl")) 0)(princ "\nDialog File not Found")) ((not (new_dialog "MAIN" DCL_ID))(princ "\nDialog Definition not Found")) (t))) (set_tile "TOG1" T:OG1$) (action_tile "TOG1" "(setq T:OG1$ $value)") (action_tile "accept" "(done_dialog)(setq button T)") (action_tile "cancel" "(done_dialog)(setq button nil)") (start_dialog)(unload_dialog DCL_ID) (setq TOG1$ T:OG1$) (if button (cond ((= TOG1$ "1")(princ "Toggle is on.")) ((= TOG1$ "0")(princ "Toggle is off.")) ) ) (princ) ) Forgot to mention, The toggle can be used in several ways to mean: On/Off, Yes/No, Do This/Do That, True/False etc etc etc. I used it on this code with a string. Can also be used with integers and reals as well. Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted March 20, 2010 Share Posted March 20, 2010 This lisp will operate two functions to give you another idea how to use the toggle. TOGGLE2.DCL MAIN : dialog { label = "Toggle2"; : boxed_column { label = "Snap Angle"; : toggle { label = "On/Off"; key = "TOG2"; } } : boxed_column { label = "Control Buttons"; : button { label = "&Proceed"; key = "accept"; width = 18; fixed_width = true; alignment = right; is_default = true; } : button { label = "&Exit Program"; key = "cancel"; width = 18; fixed_width = true; alignment = right; is_cancel = true; } } } TOGGLE2.LSP (defun C:TOGGLE2 (/ TOG2$) (or T:OG2$ (setq T:OG2$ "1")) (setq DCL_ID (load_dialog "TOGGLE2.dcl")) (if (not (new_dialog "MAIN" DCL_ID)) (cond ((<= (setq DCL_ID (load_dialog "TOGGLE2.dcl")) 0)(princ "\nDialog File not Found")) ((not (new_dialog "MAIN" DCL_ID))(princ "\nDialog Definition not Found")) (t))) (set_tile "TOG2" T:OG2$) (action_tile "TOG2" "(setq T:OG2$ $value)") (action_tile "accept" "(done_dialog)(setq button T)") (action_tile "cancel" "(done_dialog)(setq button nil)") (start_dialog)(unload_dialog DCL_ID) (setq TOG2$ T:OG2$) (if button (cond ((= TOG2$ "1")(TOGON2)) ((= TOG2$ "0")(TOGOFF2)) ) ) (princ)) (defun TOGON2 () (alert "Toggle is on!") (princ)) (defun TOGOFF2 () (alert "Toggle is off!") (princ)) Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted March 21, 2010 Share Posted March 21, 2010 slimp, I took another look at your question, And I think you might be referring to the operation of mode_tile. If so, I think CAB would be able to explain it better since he wrote those portions of the program for you. I use it also, But a slight bit different than the way he used it in your program. If he does not get back to you, I will try the best I can to explain what he did. Let me know if this is what you are looking to do. At first glance from what I can see due to the amount of action_tiles that would have been required he used a global variable list and in turn this reduced the number of action_tiles needed. This is alot of information for me to try to take in at once. Its very amaziing to me how this was done, But at the same time confusing as well. It is probably one of the reasons why I shy away from global lists. At the beginning when you were working on this program, I was going in a more simpler but longer direction. I appreciate the idea that you gave me any credit for this, However this was all CAB's idea and a much better way to program although more complex for me to deal with. I think it would be best to contact CAB by PM to see if he can shed some light on this for you. I can only touch base with some of whats going on here and not give you a very detailed explaination. I doubt many others who were not involved in that thread at the time may want to go here although I am not certain. I will try my best at it. But that up to you. The Buzzard Quote Link to comment Share on other sites More sharing options...
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.