View Full Version : How to Apply "IF" Statement to RADIO BUTTON
BoKirra
2007-10-26, 10:27 AM
Hi ALL,
Can anyone solve this DCL problem? Any help would be appreciated.
I would like to give different options to a single radio button.
What I am thinking is that a "IF" condition statement would solve the problem.
I have tried but with no success.
There are two BUTTONS labeled as "Job_01" & "Job_02" in the dialog box.
Select Job_01 BUTTON & Radio Button labeled as "Selection_01" will do task as follows:
(action_tile "Radio_Button_01" ; labeled as Selection_01
"(setq Selection $key)
(mode_tile \"Edit_Box_01\" 0)
(mode_tile \"Edit_Box_02\" 0)
(mode_tile \"Edit_Box_03\" 0)
(mode_tile \"Edit_Box_04\" 1)
(mode_tile \"Edit_Box_05\" 1)"
)
Select Job_02 BUTTON & Radio Button labeled as "Selection_01" will do task as follows:
(action_tile "Radio_Button_01" ; labeled as Selection_01
"(setq Selection $key)
(mode_tile \"Edit_Box_01\" 1)
(mode_tile \"Edit_Box_02\" 1)
(mode_tile \"Edit_Box_03\" 1)
(mode_tile \"Edit_Box_04\" 0)
(mode_tile \"Edit_Box_05\" 0)"
)
I have no problems with Radio Buttons labeled as "Selection_02" & "Selection_03".
Radio Buttons labeled as "Selection_02" & "Selection_03" will associate with other tasks.
The following is the DCL file:
FirstRoutine : dialog {
label = "First Routine";
children_alignment = top;
: row {
: column {
: boxed_column {
label = "Jobs";
: button {
key = "Job_01";
label = "Job_01";
}
: button {
key = "Job_02";
label = "Job_02";
}
} //end of boxed_column
: boxed_column {
label = "Selections";
: radio_button {
key = "Radio_Button_01";
label = "Selection_01";
}
: radio_button {
key = "Radio_Button_02";
label = "Selection_02";
}
: radio_button {
key = "Radio_Button_03";
label = "Selection_03";
}
} //end of boxed_column
} // end of column
: boxed_column {
:text { label = "Dimension_01:";}
: edit_box { alignment = left;
edit_width=10;
key = "Edit_Box_01";
}
:text { label = "Dimension_02:";}
: edit_box { alignment = left;
edit_width=10;
key = "Edit_Box_02";
}
:text { label = "Dimension_03:";}
: edit_box { alignment = left;
edit_width=10;
key = "Edit_Box_03";
}
:text { label = "Dimension_04:";}
: edit_box { alignment = left;
edit_width=10;
key = "Edit_Box_04";
}
:text { label = "Dimension_05:";}
: edit_box { alignment = left;
edit_width=10;
key = "Edit_Box_05";
}
} //end of column
} //end of row
:row { alignment = centered; fixed_height = true;
fixed_width = true;
ok_cancel;
} //end of row
} // end of FirstRoutine
Hi
Give this a try
(defun run_dial (/ dcl_id)
(setq dcl_id (load_dialog "FirstRoutine.dcl"))
(if (not (new_dialog "FirstRoutine" dcl_id))
(progn (exit)(princ)))
(action_tile "Radio_Button_01" "(setq Selection $key)(do_action 1)")
(action_tile "Radio_Button_02" "(setq Selection $key)(do_action 2)")
(action_tile "Radio_Button_03" "(setq Selection $key)(do_action 3)")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(setq knock (start_dialog))
(unload_dialog dcl_id)
)
(defun do_action (pos / )
(cond
((= pos 1)
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 1))
((= pos 2)
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 0))
((= pos 3)
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 0)
)
)
)
(defun C:BB()
(run_dial)
(if (= knock 1)
(progn
(alert "OK")
;;;<<another code follows here>>
)
)
)
CAB2k
2007-10-27, 12:19 AM
Another version with new DCL
(defun run_dial (/ dcl_id knock jb rb)
(setq dcl_id (load_dialog "FirstRoutine.dcl"))
(if (not (new_dialog "FirstRoutine" dcl_id))
(progn (exit) (princ))
)
(setq rb 0)
(set_tile "Job_01" "1")
(action_tile "Job_01" "(setq jb 0)(do_action jb rb)")
(action_tile "Job_02" "(setq jb 1)(do_action jb rb)")
(setq rb 0)
(set_tile "Radio_Button_01" "1")
(action_tile "Radio_Button_01" "(setq rb 0)(do_action jb 0)")
(action_tile "Radio_Button_02" "(setq rb 1)(do_action jb 1)")
(action_tile "Radio_Button_03" "(setq rb 2)(do_action jb 2)")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(do_action jb rb)
(setq knock (start_dialog))
(unload_dialog dcl_id)
knock
)
(defun do_action (jbp rbp /)
(cond
((and (= jbp 0) (= rbp 0))
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 1)
)
((and (= jbp 1) (= rbp 0))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 0)
)
((and (= jbp 0) (= rbp 1))
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 0)
)
((and (= jbp 1) (= rbp 1))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 1)
)
((= rbp 2)
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 0)
)
)
)
(defun C:BB ()
(if (= (run_dial) 1)
(progn
(alert "OK")
;;;<<another code follows here>>
)
)
)
FirstRoutine : dialog { label = "First Routine"; children_alignment = top;
: row {
: column {
: boxed_column { label = "Jobs";
: radio_column {
: radio_button { key = "Job_01"; label = "Job_01"; }
: radio_button { key = "Job_02"; label = "Job_02"; }
}
} //end of boxed_column
: boxed_column { label = "Selections";
: radio_column {
: radio_button { key = "Radio_Button_01"; label = "Selection_01"; }
: radio_button { key = "Radio_Button_02"; label = "Selection_02"; }
: radio_button { key = "Radio_Button_03"; label = "Selection_03"; }
}
} //end of boxed_column
} // end of column
: boxed_column {
: edit_box { label = "Dimension_01:"; edit_width=10; key = "Edit_Box_01"; }
: edit_box { label = "Dimension_02:"; edit_width=10; key = "Edit_Box_02"; }
: edit_box { label = "Dimension_03:"; edit_width=10; key = "Edit_Box_03"; }
: edit_box { label = "Dimension_04:"; edit_width=10; key = "Edit_Box_04"; }
: edit_box { label = "Dimension_05:"; edit_width=10; key = "Edit_Box_05"; }
} //end of column
} //end of row
:row { alignment = centered; fixed_height = true; fixed_width = true;
ok_cancel;
} //end of row
}
BoKirra
2007-10-31, 03:38 AM
Hi
Give this a try
...
Thanks for your help & I've learnt from it.
It's a great lesson for learning "COND".
BoKirra
2007-10-31, 04:02 AM
Another version with new DCL
...
Your code is good when routines are more complicated.
It's good to learn from you.
ANOTHER QUESTION is how to make the setting as default?
For example, if I want to do "Job_02" with "Selection_01" AGAIN later, I'd like it to be set to "Job_02" & "Selection_01" with "Dimension_01~03" frozen automatically when I reopen the dialog box.
It will save time.
Thanks again!
CAB2k
2007-10-31, 04:16 AM
Try this:
(defun run_dial (/ dcl_id knock jb rb)
(setq dcl_id (load_dialog "FirstRoutine.dcl"))
(if (not (new_dialog "FirstRoutine" dcl_id))
(progn (exit) (princ))
)
(setq jb 2)
(set_tile "Job_02" "1")
(action_tile "Job_01" "(setq jb 1)(do_action jb rb)")
(action_tile "Job_02" "(setq jb 2)(do_action jb rb)")
(setq rb 1)
(set_tile "Radio_Button_01" "1")
(action_tile "Radio_Button_01" "(setq rb 1)(do_action jb 1)")
(action_tile "Radio_Button_02" "(setq rb 2)(do_action jb 2)")
(action_tile "Radio_Button_03" "(setq rb 3)(do_action jb 3)")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(do_action jb rb)
(setq knock (start_dialog))
(unload_dialog dcl_id)
knock
)
(defun do_action (jbp rbp /)
(cond
((and (= jbp 1) (= rbp 1))
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 1)
)
((and (= jbp 2) (= rbp 1))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 0)
)
((and (= jbp 1) (= rbp 2))
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 0)
)
((and (= jbp 2) (= rbp 2))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 1)
)
((= rbp 3)
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 0)
)
)
)
(defun C:BB ()
(if (= (run_dial) 1)
(progn
(alert "OK")
;;;<<another code follows here>>
)
)
)
CAB2k
2007-10-31, 04:19 AM
ke.li
Be sure you read this thread:
http://forums.augi.com/showthread.php?p=602355&postcount=10
BoKirra
2007-10-31, 06:15 AM
Try this:
...
With your code, it sets to "Job_02" with "Selection_01" by default.
Perhaps I confused you.
Let me state it clearer:
Firstly, supposed I did a job (it could be any selections). for example, I did "Job_02" with "Selection_01".
Now I want to reopen the dialog box & I'd like it to be set to the previous job automatically.
Thanks again.
ElpanovEvgeniy
2007-10-31, 08:21 AM
Hello Alan! :)
line 14:
(action_tile "Radio_Button_01" "(setq rb 1)(do_action jb 0)")
(do_action jbp rbp) =>
rbp = 0 ??
ElpanovEvgeniy
2007-10-31, 08:25 AM
Variant with my corrections...
(defun run_dial-1 (/ dcl_id knock jb rb)
(setq dcl_id (load_dialog "FirstRoutine.dcl"))
(if (not (new_dialog "FirstRoutine" dcl_id))
(progn (exit) (princ))
) ;_ if
(setq jb 2)
(set_tile "Job_02" "1")
(foreach i '(1 2)
(action_tile (strcat "Job_0" (itoa i)) (strcat "(do_action (setq jb " (itoa i) ") rb)"))
) ;_ foreach
(setq rb 1)
(set_tile "Radio_Button_01" "1")
(foreach i '(1 2 3)
(action_tile (strcat "Radio_Button_0" (itoa i))
(strcat "(setq rb " (itoa i) ") (do_action jb " (itoa i) ")")
) ;_ action_tile
) ;_ foreach
(action_tile "cancel" "(done_dialog 0)")
(do_action jb rb)
(setq knock (start_dialog))
(unload_dialog dcl_id)
knock
) ;_ defun
CAB2k
2007-10-31, 03:10 PM
Hello Alan! :)
line 14:
(do_action jbp rbp) =>
rbp = 0 ??
Thanks Evgeniy,
I reassigned the button values & missed those. Changed code in post.:)
CAB2k
2007-10-31, 03:20 PM
ke.li
Yes you did confuse me.
See below a revised lisp.
Note that Evgeniy provided a lisp with more efficent code, but it my be harder for you to read at
this point in your development.
<edit: code removed, see updated code in another post>
BoKirra
2007-11-01, 12:15 AM
See below a revised lisp.
...
Again, you set Job_02 & Selection_01 as default by the following lines:
(set_tile "Job_02" "1")
(set_tile "Radio_Button_01" "1")
It's alright to me.
But the problem is that if I did another job, for example - "Job_01" & Selection_02", it won't return when I reopen the dialog box.
CAB2k
2007-11-01, 12:32 AM
Ok, try this. It will be set to the same buttons where you left it.
This is for one drawing only, if you switch drawings it will remember
a seperate jb & rb.
(defun run_dial (/ dcl_id knock)
;; global variable jb & rb
(setq dcl_id (load_dialog "FirstRoutine.dcl"))
(if (not (new_dialog "FirstRoutine" dcl_id))
(progn (exit) (princ))
)
(if jb
(set_tile (strcat "Job_0" (itoa jb)) "1")
(progn
(setq jb 1) ; first time through
(set_tile "Job_01" "1")
)
)
(action_tile "Job_01" "(setq jb 1)(do_action jb rb)")
(action_tile "Job_02" "(setq jb 2)(do_action jb rb)")
(if rb
(progn
(set_tile (strcat "Radio_Button_0" (itoa rb)) "1")
)
(progn
(setq rb 1)
(set_tile "Radio_Button_01" "1")
)
)
(action_tile "Radio_Button_01" "(setq rb 1)(do_action jb 1)")
(action_tile "Radio_Button_02" "(setq rb 2)(do_action jb 2)")
(action_tile "Radio_Button_03" "(setq rb 3)(do_action jb 3)")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(do_action jb rb)
(setq knock (start_dialog))
(unload_dialog dcl_id)
knock
)
(defun do_action (jbp rbp /)
(cond
((and (= jbp 1) (= rbp 1))
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 1)
)
((and (= jbp 2) (= rbp 1))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 0)
)
((and (= jbp 1) (= rbp 2))
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 0)
)
((and (= jbp 2) (= rbp 2))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 1)
)
((= rbp 3)
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 0)
)
)
)
(defun C:BB ()
(if (= (run_dial) 1)
(progn
(alert "OK")
;;;<<another code follows here>>
)
)
)
BoKirra
2007-11-01, 02:23 AM
Ok, try this. It will be set to the same buttons where you left it.
This is for one drawing only, if you switch drawings it will remember
a seperate jb & rb.
(defun run_dial (/ dcl_id knock)
...
)
Thanks for your immediate reply & your great help.
YES, this is what I dreamt for a long long time.
CAB2k
2007-11-01, 05:21 AM
Glad I could help.:)
BoKirra
2007-11-02, 12:53 AM
Glad I could help.:)
I wish I can fully understand your code.
I have also modified yours and shown it below.
What I tried to do was to freeze all dimension boxes when the routine FIRST loaded. It looks working to me. But I am not sure if it is alright.
Could you please have a look the details added. I've already added notes beside.
Thanks again.
;>>>>>>>>>>> Dummy button added to set all dimension boxes frozen when this routine first loaded.
(defun run_dial (/ dcl_id knock)
;; global variable jb & rb
(setq dcl_id (load_dialog "FirstRoutine.dcl"))
(if (not (new_dialog "FirstRoutine" dcl_id))
(progn (exit) (princ))
)
(if jb
(set_tile (strcat "Job_0" (itoa jb)) "1")
(progn
(setq jb 1) ; first time through
(set_tile "Job_00" "1") ;Make dummy button's settings as default
)
)
(action_tile "Job_00" "(setq jb 1)(do_action jb rb)") ;Dummy button added but not shown.
(action_tile "Job_01" "(setq jb 2)(do_action jb rb)")
(action_tile "Job_02" "(setq jb 3)(do_action jb rb)")
(if rb
(progn
(set_tile (strcat "Radio_Button_0" (itoa rb)) "1")
)
(progn
(setq rb 1)
(set_tile "Radio_Button_01" "1")
)
)
(action_tile "Radio_Button_00" "(setq rb 1)(do_action jb 1)") ;Dummy button added but not shown.
(action_tile "Radio_Button_01" "(setq rb 2)(do_action jb 2)")
(action_tile "Radio_Button_02" "(setq rb 3)(do_action jb 3)")
(action_tile "Radio_Button_03" "(setq rb 4)(do_action jb 4)")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(do_action jb rb)
(setq knock (start_dialog))
(unload_dialog dcl_id)
knock
)
(defun do_action (jbp rbp /)
(cond
((and (= jbp 1) (= rbp 1))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 1)
)
((and (= jbp 2) (= rbp 2))
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_01" 2) ;Set focus to the first Dimension tile
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 1)
)
((and (= jbp 3) (= rbp 2))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_04" 2) ;Set focus to the first Dimension tile
(mode_tile "Edit_Box_05" 0)
)
((and (= jbp 2) (= rbp 3))
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_01" 2) ;Set focus to the first Dimension tile
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 0)
)
((and (= jbp 3) (= rbp 3))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_02" 2) ;Set focus to the first Dimension tile
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 1)
)
((= rbp 4)
(mode_tile "Edit_Box_01" 0)
(mode_tile "Edit_Box_01" 2) ;Set focus to the first Dimension tile
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 0)
)
)
)
(defun C:BB ()
(if (= (run_dial) 1)
(progn
(alert "OK")
;;;<<another code follows here>>
)
)
)
CAB2k
2007-11-02, 02:51 AM
No need for the false buttons.
Try this, although i messed up your edit modes.
(defun run_dial (/ dcl_id knock)
;; global variable jb & rb
(setq dcl_id (load_dialog "FirstRoutine.dcl"))
(if (not (new_dialog "FirstRoutine" dcl_id))
(progn (exit) (princ))
)
(if jb
(set_tile (strcat "Job_0" (itoa jb)) "1")
(setq jb 0) ; first time through
)
(action_tile "Job_01" "(setq jb 1)(do_action jb rb)")
(action_tile "Job_02" "(setq jb 2)(do_action jb rb)")
(if rb
(set_tile (strcat "Radio_Button_0" (itoa rb)) "1")
(setq rb 0)
)
(action_tile "Radio_Button_01" "(setq rb 1)(do_action jb rb)")
(action_tile "Radio_Button_02" "(setq rb 2)(do_action jb rb)")
(action_tile "Radio_Button_03" "(setq rb 3)(do_action jb rb)")
(action_tile "accept" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(do_action jb rb)
(setq knock (start_dialog))
(unload_dialog dcl_id)
knock
)
(defun do_action (jbp rbp /)
(and (zerop rbp) (not(zerop jbp))
(setq rbp 1 rb 1)
(set_tile "Radio_Button_01" "1"))
(cond
((and (= jbp 1) (= rbp 1))
(mode_tile "Edit_Box_01" 2) ;Set focus to the first Dimension tile
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 1)
)
((and (= jbp 1) (= rbp 2))
(mode_tile "Edit_Box_01" 2) ;Set focus to the first Dimension tile
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 0)
)
((and (= jbp 2) (= rbp 1))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 2) ;Set focus to the first Dimension tile
(mode_tile "Edit_Box_05" 0)
)
((and (= jbp 2) (= rbp 2))
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 2) ;Set focus to the first Dimension tile
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 1)
)
((and (= jbp 2) (= rbp 3))
(mode_tile "Edit_Box_01" 2) ;Set focus to the first Dimension tile
(mode_tile "Edit_Box_02" 0)
(mode_tile "Edit_Box_03" 0)
(mode_tile "Edit_Box_04" 0)
(mode_tile "Edit_Box_05" 0)
)
((= rbp 4)
)
((= jbp 0)
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 1)
)
)
)
(defun C:BB ()
(if (= (run_dial) 1)
(progn
(alert "OK")
;;;<<another code follows here>>
)
)
)
BoKirra
2007-11-02, 03:59 AM
No need for the false buttons.
Try this, although i messed up your edit modes.
...
((= rbp 4)
)
((= jbp 0)
(mode_tile "Edit_Box_01" 1)
(mode_tile "Edit_Box_02" 1)
(mode_tile "Edit_Box_03" 1)
(mode_tile "Edit_Box_04" 1)
(mode_tile "Edit_Box_05" 1)
)
...
Could you explain why "rbp = 4" & "jbp = 0" as shown above?
Thanks!
CAB2k
2007-11-02, 05:27 AM
((= jbp 0) is the condition for the first time through the lisp.
((= rbp 4) does nothing & I should have removed it.
BoKirra
2007-11-02, 07:11 AM
((= jbp 0) is the condition for the first time through the lisp.
((= rbp 4) does nothing & I should have removed it.
It is clear now.
Thanks & :beer: !
BoKirra
2007-11-08, 12:45 AM
ke.li
Be sure you read this thread:
http://forums.augi.com/showthread.php?p=602355&postcount=10
Could you please explain what is the difference between "and" & "progn"?
They make me headache for a long long time.
Thanks.
CAB2k
2007-11-08, 03:34 PM
Well PROGN and AND can be use to group code together, but AND will stop evaluating the grouped code
when any line returns nil.
AND returns True or nil only.
Progn continues to the last expression & returns the value of the last expression.
(and
(= 1 1) ; returns True, do not quit
(+ 1 1) ; returns 2, do not quit
(= 0 1) ; returns nil, stop evaluating
(+ 2 2) ; this line is not executed
)
Returns nil
(and
(= 1 1) ; returns True, do not quit
(+ 1 1) ; returns 2, do not quit
(+ 2 2) ; returns 4, as this is not nil the AND is complete
)
Returns true
Now PROGN is basically a code wrapper. It wraps a group of code & returns the result of the last expression.
(progn
(= 1 1) ; returns True
(+ 1 1) ; returns 2
(= 0 1) ; returns nil
(+ 2 2) ; returns 4
)
Returns 4
I usually only use PROGN with the IF and WHILE functions.
BoKirra
2007-11-09, 12:15 AM
Well PROGN and AND can be use to group code together, but AND will stop evaluating the grouped code
when any line returns nil.
AND returns True or nil only.
Progn continues to the last expression & returns the value of the last expression.
...
I usually only use PROGN with the IF and WHILE functions.
Thanks again.
The following is two statements comparing with "PROGN" & "AND":
Which one is the correct one?
Statement 1
(if (and (= jbp 1) (= rbp 1))
(PROGN (command "pline" Point1 Point2 "")
(command "pline" IP Point3 Point4 Point5 IP Point6 Point7 ""))
) ;end if
Statement 2
(if (and (= jbp 1) (= rbp 1))
(AND (command "pline" Point1 Point2 "")
(command "pline" IP Point3 Point4 Point5 IP Point6 Point7 ""))
) ;end if
CAB2k
2007-11-09, 01:12 AM
Statement 1 is the correct usage in that example.
BoKirra
2007-11-09, 02:17 AM
Statement 1 is the correct usage in that example.
Thank you very much!
:lol: :beer: :lol: :beer: :lol:
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.