I am frustrating with checkboxes...
I want to run function on "OK" while checkbox is checked. But I tried to run while checked - it works, and then after I uncheck the box and hit "OK" the program runs again. This dives me insane for 7 hours straight.
(defun c:TIDstd_Form1_CheckBox3D_OnClicked (Value /)
(if (> Value 0)
(c:3DSTD)
)
)
Please help.
I'm not sure I understand the problem. Perhaps you should be using the form's OnOK event instead of the check box OnClicked event?
Here is the code:
============
(defun c:Project ()
(dcl_Project_Load "Q:\\folder\\Project.odcl" T)
(dcl_Form_Show Project_Form1)
(princ)
)
(defun c:Project_Form1_TextButtonOK_OnClicked (/)
(dcl_Form_Close Project_Form1)
)
(defun c:Project_Form1_OnOk (/)
(dcl_Form_Close Project_Form1)
)
(defun c:Project_Form1_CheckBox3D_OnClicked (Value /)
(dcl_Control_GetValue Project_Form1_CheckBox3D)
(if (> Value 0)
(c:3DSTD)
)
)
(defun c:Project_Form1_TextButton3D_OnClicked (/)
(dcl_Control_SetValue Project_Form1_CheckBox3D 1 )
)
(defun c:Project_Form1_TextButtonCl_OnClicked (/)
(dcl_Control_SetValue Project_Form1_CheckBox3D 0)
)
============
See pic attached,
All I want is to click on either Text Button, so checkbox is checked, or just checkbox check and run (c:do) on "OK"-button click.
For now it works only when I first time check checkbox, it did not work when I click on text-button even though the checkbox becomes checked.
And, what drives me crazy the most is (c:do) runs when I uncheck the checkbox...
I would appreciate any advise.
You refer to (c:do), but the code you posted has no mention of (c:do), and instead it includes a (c:3DSTD) function that is not defined. What is (c:d0), and when exactly should it be executing? Your attached image suggests that it should execute when OK is pressed, and I guess probably only if the check box is checked. In that case you need to remove the check box OnClicked handler and either:
1) Put that code in your OnOk handler:
(defun c:Project_Form1_OnOk (/)
(if (> (dcl_Control_GetValue Project_Form1_CheckBox3D) 0) (c:d0))
(dcl_Form_Close Project_Form1)
)
or 2) Return a suitable value and call (c:d0) from your (c:Project) function:
(defun c:Project ()
(dcl_Project_Load "Q:\\folder\\Project.odcl" T)
(if (= 4 (dcl_Form_Show Project_Form1)) (c:do))
(princ)
)
(defun c:Project_Form1_OnOk (/)
; return either 3 (unchecked) or 4 (checked)
(dcl_Form_Close Project_Form1 (+ 3 (dcl_Control_GetValue Project_Form1_CheckBox3D)))
)