Using Radio Buttons in a nested If Statement

stanovb
Advocate

Using Radio Buttons in a nested If Statement

stanovb
Advocate
Advocate

I'm having a little trouble making this work. I have a program called Updatecover that's supposed to delete and/or rename tabs based on a selection. It works on one selection, but if i have multiple radio button selections to make this is where I am running into a problem. There is also a dcl file that is associated with each project type. It could be SAO or it could be MRP. 

stanovb_0-1737417396467.png

so in this instance the building shape would be either narrow or wide and it would be nested under Cellar and 1st floor if statement. I can get the first one to work but not the 2nd. It never gets down to the 2nd part. How do i get it to differentiate between a narrow or wide selection under the cellaronefloor umbrella?

This is located here in the code:

stanovb_1-1737418281705.png

 

0 Likes
Reply
262 Views
6 Replies
Replies (6)

Sea-Haven
Mentor
Mentor

Code is missing a ERROR: NO TITLE INFORMATION FILE EXISTS.

 

But that aside if you use (get_tile "cellaroneflr")  it will return a "1" if selected or a "0" if not hopes that helps. I use a little defun that can loop through a row of buttons and find which one was picked. But obviously button names are critical.

 

(defun butval4 ( / l)
(setq x 1)
(repeat 4
    (setq l (strcat "Rb" (rtos x 2 0)))
    (if  (= (get_tile l) "1" )
        (setq but x)
    )
    (setq x (+ x 1))
)
(princ but)
)

 

 

 

0 Likes

stanovb
Advocate
Advocate

sorry, I should have sent that in another post. The forum limits me to 3 attachments

0 Likes

scot-65
Advisor
Advisor

@stanovb 

Please see the revised DCL file for hints and tricks.

I did not view your LSP file.

 

The objective when working with dialogs is to gather user input first before executing the rest of your program.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


0 Likes

paullimapa
Mentor
Mentor

Next time when you have more than three then zip all into one file and attach that zip file


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

paullimapa
Mentor
Mentor

Lots of xref dwgs not found including the title block xref.

Use the eTransmit command to zip all xrefs into a single file and then upload here

paullimapa_0-1737564513650.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

paullimapa
Mentor
Mentor

"so in this instance the building shape would be either narrow or wide and it would be nested under Cellar and 1st floor if statement. I can get the first one to work but not the 2nd. It never gets down to the 2nd part. How do i get it to differentiate between a narrow or wide selection under the cellaronefloor umbrella?"

 

Perhaps you can clarify the above statement.

So your BUILDING TYPE has the following radio button selections:

paullimapa_0-1737571893901.png

Now when the dialog first appears for user selection with radio buttons one of them should be automatically selected and not none. So for Cellar And First Floor to be selected your dcl file would add this line:

 

    : radio_button {
    label = "Cellar And First Floor";
    key   = "cellaroneflr";
    value = "1";   
  }

 

But your lisp code contains this section that overrides this:

 

    (set_tile "cellaroneflr"
	      (if cellaroneflr
		;; Check Flag
		"1"
		;; If non-nil, Set toggle to on
		"0"
		;; else set toggle to off
	      )
    )

 

I would make the following change in your lisp code so that Cellar And First Floor first appears selected under BUILDING TYPE:

 

    (setq buildingtype "cellaroneflr") ; set this value
    (set_tile buildingtype "1") ; select radio button

 

Then like the BUILDING TYPE, the BUILDING SHAPE section needs to have an initial selection:

paullimapa_1-1737574781503.png

So again you can either include the value = "1"; line in the dcl or in your lisp code so that at least one of the shapes in this case Narrow Building is selected under BUILDING SHAPE:

 

    (setq buildingshape "narrow") ; set this value
    (set_tile buildingshape "1") ; select radio button

 

Currently you have the following call back action statements on the radio buttons:

 

(action_tile "cellaroneflr" "(setq cellaroneflr (not cellaroneflr))")
(action_tile "cellartwoflr" "(setq cellartwoflr (not cellartwoflr))")    
(action_tile "oneflr" "(setq oneflr (not oneflr))")
(action_tile "twoflr" "(setq twoflr (not twoflr))")
(action_tile "wide" "(setq wide (not wide))")
(action_tile "narrow" "(setq narrow (not narrow))")

 

I would change them to this method:

 

; for building type:
(foreach tile '("cellaroneflr" "cellartwoflr" "oneflr" "twoflr")(action_tile tile "(setq buildingtype $key)")
; for building shape
(foreach tile '("wide" "narrow")(action_tile tile "(setq buildingshape $key)")
 

 

 So the remainder of your code would check which dcl key value is stored in the buildingtype and buildingshape variables to proceed like this:

 

; for building type:
(cond
 ((eq buildingtype "cellaroneflr")
  ;;; do code here
 )
 ((eq buildingtype "cellartwoflr")
  ;;; do code here
 )
 ((eq buildingtype "oneflr")
  ;;; do code here
 )
 ((eq buildingtype "twoflr")
  ;;; do code here
 )
)
  
; for building shape
(cond
 ((eq buildingshape "wide")
  ;;; do code here
 )
 ((eq buildingshape "narrow")
  ;;; do code here
 )
)  

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes