TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Ron Heigh on December 01, 2004, 11:16:07 AM

Title: DCL radiobutton alignment
Post by: Ron Heigh on December 01, 2004, 11:16:07 AM
Is there a way to have 2 columns of radio buttons that are linked?
Such that if I check the button on column 2 the radio button on column 1 is unchecked?
Title: DCL radiobutton alignment
Post by: CAB on December 01, 2004, 11:36:05 AM
Have not tried it but this mught work:

Code: [Select]
: boxed_radio_column { //define boxed radio column
       label = "Pick a color";
  : row {
    : radio_button { //define radio button
       label = "White"; //give it a label
       key = "rb1"; //give it a name
    }
    : radio_button {
       label = "Green";
       key = "rb2";
    }
  }
  : row {
    : radio_button { //define radio button
       label = "Red"; //give it a label
       key = "rb3"; //give it a name
    }
    : radio_button {
       label = "Yellow";
       key = "rb4";
    }
  }
}
Title: DCL radiobutton alignment
Post by: Crank on December 01, 2004, 12:57:13 PM
Here is 1 example:
Code: [Select]

// TEST.DCL

// Profiel-insertroutine  Copyright (c) '94/'04 J.J.Damstra
// For demonstration only (published on 'the Swamp' on 11-31-'04

dcl_settings : default_dcl_settings { audit_level = 3; }

profiel : dialog {
    label = "PROFIEL DEMO";

    : row {
: column {
: boxed_row {
   label = "Profieltype:";
   key = "type";
   : radio_column {
: radio_button {
label = "Buis-profielen (CHS)";
key = "buis";
}
spacer_1;
: radio_button {
label = "Damwanden (diverse typen)";
key = "damwand";
}
spacer_1;
: radio_button {
label = "DIE; DIL; DIN; DIR en DIH";
key = "dix";
}
spacer_1;
: radio_button {
label = "Geïntergreerde ligger, type: ASB";
key = "asb";
}
: radio_button {
label = "Geïntergreerde ligger, type: IFB";
key = "ifb";
}
: radio_button {
label = "Geïntergreerde ligger, type: SFB";
key = "sfb";
}
: radio_button {
label = "Geïntergreerde ligger, type: THQ";
key = "thq";
}
spacer_1;
: radio_button {
label = "HEAA-profiel";
key = "heaa";
}
: radio_button {
label = "HEA-profiel";
key = "hea";
}
: radio_button {
label = "HEB-profiel";
key = "heb";
}
: radio_button {
label = "HEC-profiel";
key = "hec";
}
: radio_button {
label = "HEM-profiel";
key = "hem";
}
spacer_1;
: radio_button {
label = "HD-profiel";
key = "hd";
}
: radio_button {
label = "HL-profiel";
key = "hl";
}
spacer_1;
: radio_button {
label = "IPE-profiel";
key = "ipe";
}
: radio_button {
label = "IPE A;  IPE O;  IPE V en IPE 750";
key = "ipe-a";
}
}
   : radio_column {
: radio_button {
label = "INP-profiel";
key = "inp";
}
spacer_1;
: radio_button {
label = "Hoeklijn gelijkzijdig";
key = "hoek1";
}
: radio_button {
label = "Hoeklijn ongelijkzijdig";
key = "hoek2";
}
spacer_1;
: radio_button {
label = "Koker gelijkzijdig     (RHS)";
key = "koker1";
}
: radio_button {
label = "Koker ongelijkzijdig (RHS)";
key = "koker2";
}
spacer_1;
: radio_button {
label = "MONTAN-profiel";
key = "montan";
}
spacer_1;
: radio_button {
label = "Platstaal/Strip";
key = "strip";
}
spacer_1;
: radio_button {
label = "Raatligger";
key = "raat";
}
spacer_1;
: radio_button {
label = "Rails";
key = "rails";
}
spacer_1;
: radio_button {
label = "T-staal   (1:1)";
key = "T-staal1";
}
: radio_button {
label = "TB-staal (2:1)";
key = "T-staal2";
}
spacer_1;
: radio_button {
label = "UAP-profiel";
key = "uap";
}
: radio_button {
label = "UPE-profiel";
key = "upe";
}
spacer_1;
: radio_button {
label = "UNP-profiel";
key = "unp";
}
spacer_1;
: radio_button {
label = "Z-profiel";
key = "z";
}
   }
}
}
    }

    spacer_1;
    ok_cancel_err;
}


Code: [Select]

(defun c:test (/ profiel)
(setq dcl_id (load_dialog "test.dcl"))
(if (not (new_dialog "profiel" dcl_id)) (exit))

(action_tile "buis" "(wis2)(buis)")
(action_tile "damwand" "(wis2)(damwand)")
(action_tile "dix" "(wis2)(dix)")
(action_tile "heaa" "(wis2)(heaa)")
(action_tile "hea" "(wis2)(hea)")
(action_tile "heb" "(wis2)(heb)")
(action_tile "hec" "(wis2)(hec)")
(action_tile "hem" "(wis2)(hem)")
(action_tile "hd" "(wis2)(hd)")
(action_tile "hl" "(wis2)(hl)")
(action_tile "asb" "(wis2)(asb)")
(action_tile "ifb" "(wis2)(ifb)")
(action_tile "sfb" "(wis2)(sfb)")
(action_tile "thq" "(wis2)(thq)")
(action_tile "ipe" "(wis2)(ipe)")
(action_tile "ipe-a" "(wis2)(ipe-a)")
(action_tile "inp" "(wis1)(inp)")
(action_tile "hoek1" "(wis1)(hoek1)")
(action_tile "hoek2" "(wis1)(hoek2)")
(action_tile "koker1" "(wis1)(koker1)")
(action_tile "koker2" "(wis1)(koker2)")
(action_tile "montan" "(wis1)(montan)")
(action_tile "raat" "(wis1)(raat)")
(action_tile "rails" "(wis1)(rails)")
(action_tile "strip" "(wis1)(strip)")
(action_tile "T-staal1" "(wis1)(t1)")
(action_tile "T-staal2" "(wis1)(t2)")
(action_tile "uap" "(wis1)(uap)")
(action_tile "upe" "(wis1)(upe)")
(action_tile "unp" "(wis1)(unp)")
(action_tile "z" "(wis1)(z-prof)")

(action_tile "accept" "(done_dialog 1)(setq profiel 1")
(action_tile "cancel" "(done_dialog 0)(setq profiel 0)")

  (while (not profiel)(start_dialog))
  (alert "Your program starts here")
  (princ)
)

(defun message (bericht)
(set_tile "error" bericht)
)
(defun asb ()
(message "ASB-geïntergreerde ligger")
)
(defun buis ()
(message "Buisprofielen")
)
(defun damwand ()
(message "Diverse stalen damwandprofielen")
)
(defun dix ()
(message "Antieke profielen")
)
(defun heaa ()
(message "HEAA-profielen")
)
(defun hea ()
(message "HEA-profielen")
)
(defun heb ()
(message "HEB-profielen")
)
(defun hec ()
(message "HEC-profiel")
)
(defun hem ()
(message "HEM-profielen")
)
(defun hl ()
(message "HL-profielen")
)
(defun hd ()
(message "HD-profielen")
)
(defun ipe ()
(message "IPE-profielen")
)
(defun ipe-a ()
(message "IPE A;  IPE O;  IPE V en IPE 750")
)
(defun ifb ()
(message "IFB-geïntergreerde ligger")
)
(defun inp ()
(message "INP-profielen")
)
(defun hoek1 ()
(message "Gelijkzijdige hoeklijnen")
)
(defun hoek2 ()
(message "Ongelijkzijdige hoeklijnen")
)
(defun koker1 ()
(message "Gelijkzijdige kokerprofielen")
)
(defun koker2 ()
(message "Ongelijkzijdige kokerprofielen")
)
(defun montan ()
(message "MONTAN-profiel")
)
(defun raat ()
(message "Raatliggers")
)
(defun rails ()
(message "Kraanbaanliggers en spoorrails")
)
(defun sfb ()
(message "SFB-geïntergreerde ligger")
)
(defun strip ()
(message "Platstaal en strippen")
)
(defun t1 ()
(message "T-staal (gelijkzijdig)")
)
(defun t2 ()
(message "TB-staal (ongelijkzijdig)")
)
(defun thq ()
(message "THQ-geïntergreerde ligger")
)
(defun uap ()
(message "UAP-profielen")
)
(defun upe ()
(message "UPE-profielen")
)
(defun unp ()
(message "UNP-profielen")
)
(defun z-prof ()
(message "Z-profielen")
)

(defun wis1 ()(set_tile "buis" "2")(set_tile "buis" "0"))
(defun wis2 ()(set_tile "unp" "2")(set_tile "unp" "0"))
(princ)
Title: DCL radiobutton alignment
Post by: Ron Heigh on December 02, 2004, 07:48:12 AM
Thanks guys.

Both of your responses result in me having 2 radio buttons with value=1 at the same time.

I need to have multiple columns of radio buttons, with only one "DOT" at any given time enabled.
Title: DCL radiobutton alignment
Post by: Ron Heigh on December 02, 2004, 08:39:08 AM
I redid my dialog to use a list box instead of multiple columns.
I'd love to see this problem solved though.

Thanks for the help everyone.
Title: DCL radiobutton alignment
Post by: Crank on December 02, 2004, 02:39:38 PM
Code: [Select]

....
(defun wis1 ()(set_tile "buis" "2")(set_tile "buis" "0"))
(defun wis2 ()(set_tile "unp" "2")(set_tile "unp" "0"))
....

When you select a button from column2, the program selects the first button of column1 and clears it inmedeally. And for every button of column1 it does the same in column2.

Quote from: Ron Heigh
...Both of your responses result in me having 2 radio buttons with value=1 at the same time.
...

You can set a flag in the action_tile function and use that later in your program.
Title: DCL radiobutton alignment
Post by: Keith™ on December 02, 2004, 11:20:08 PM
Ok, Now that everyone has had their say....

A set of radio buttons can be grouped together without additional code by following this format:
Code: [Select]

      : radio_cluster {
              :row {
            : column {
             : radio_button {
              label = "R1";
              key = "R1";
              }
             : radio_button {
              label = "R2";
              key = "R2";
              }
             : radio_button {
              label = "R3";
              key = "R3";
              }
             }
            : column {
             : radio_button {
              label = "R4";
              key = "R4";
              }
             : radio_button {
              label = "R5";
              key = "R5";
              }
             : radio_button {
              label = "R6";
              key = "R6";
              }
             }
               }
              }



Note that what puts all of the radio_buttons in the same group is the :radio_cluster designation
This example has 2 columns with 3 buttons each. You could just as easily made 4 buttons or 4 columns.
Title: DCL radiobutton alignment
Post by: CAB on December 03, 2004, 07:58:23 AM
Keith
Here is the test.
Where did you find that reference to radio_cluster? :shock:
Title: DCL radiobutton alignment
Post by: Keith™ on December 03, 2004, 09:07:15 AM
Well, it certainly isn't in the documentation now is it ...  8)

Lets just say there are things not in the DCL tile catalog in the documentation.

here is a list I have and what they do

Quote

boxed_column - A column of objects with a frame
boxed_radio_column - A column of radio_buttons with a frame
boxed_radio_row - A row of radio_buttons with a frame
boxed_row    - a row with a frame
button - a simple button
cancel_button - default cancel button
cluster - clustered widgets
color_palette_0_9 - default color dialog palette for the first 10 colors
color_palette_1_7 - default color dialog palette for the ACI colors 1-7
color_palette_1_9 - default color dialog palette for the ACI colors 1-9
color_palette_250_255 - default color dialog palette for the ACI colors 250-255
column - a column of widgets
concatenation - concatenation, used for multiple text widgets
default_button - the default button designation
dialog - The window containing the widgets
edit_box - an editbox
edit12_box    - an editbox 12 characters wide with a maximum of 148 characters
edit32_box    - an editbox 32 characters wide with a maximum of 2048 characters
errtile - a text tile with the key "error"
fcf_ebox - an edit_box 7 char wide typically used in the files dialog
fcf_ebox1 - an edit_box with a limit of 3 chars
fcf_ibut - image_button 3.5 wide X 1.2 high
fcf_ibut1 - image_button 5 wide aspect ratio of 0.66
files_bottomdf - file edit_box columned with ok_cancel and errtile key = "fedit"
files_topdf - specialty cluster for files dialog
help_button - help button key = help
icon_image - image_button 12 wide aspect ratio of 0.66
image - an image tile
image_block - image height of 1 width of 1
image_button - an image tile button
info_button - predefined button key = "info"
list_box - a list box
ok_button - OK button with key = "accept"
ok_cancel - button cluster
ok_cancel_err - button cluster
ok_cancel_help - button cluster
ok_cancel_help_errtile - button cluster
ok_cancel_help_info - button cluster
ok_only - OK button with key = "accept" but is also the cancel button
paragraph   a cluster of vertical text
popup_list - a popup list
radio_button - a radio button
radio_cluster - a cluster of radio buttons
radio_column - a column of radio buttons
radio_row - a row of radio buttons
retirement_button - predefined button with a fixed width of 8
row - a row of widgets
slider - a slider mechanism
spacer - a spacer
spacer_0 - a spacer
spacer_1 - a spacer
std_rq_color - standard complete color palette with controls
swatch - a colored image button 3X1.5
text - a label
text_25 - a label 25 chars long
text_part - a label without margins typically used for paragraphs
tile - the widget
toggle - a toggle button


I am not sure if there are more or not, but these are available on all 2000+ systems
Title: DCL radiobutton alignment
Post by: Ron Heigh on December 03, 2004, 09:31:14 AM
Now is when we need the ability to award points for useful posts.
Keith would be getting my vote.
Nice work.
Title: DCL radiobutton alignment
Post by: CAB on December 03, 2004, 09:40:08 AM
Thank You Keith!
You get my vote too. :)
Title: DCL radiobutton alignment
Post by: Keith™ on December 03, 2004, 09:52:31 AM
Glad to help ....
Title: DCL radiobutton alignment
Post by: SMadsen on December 03, 2004, 10:44:04 AM
Quote from: CAB
Where did you find that reference to radio_cluster?

Most of the controls can be found in the BASE.DCL file. It loads automatically and doesn't need the include directive to be referenced.
Title: Re: DCL radiobutton alignment
Post by: TheyCallMeJohn on January 02, 2014, 07:29:47 PM
Has anyone been able to get this to work?

My code works with two radio columns but not with the radio cluster.

Code: [Select]
dcl_settings : default_dcl_settings {audit_level=3;}
tcluster : dialog { label = "2007 OPA - Mechancical Pipe - SCD 40  STD";

: radio_cluster {
: row {
: column {
: radio_button {
key = "eb0";
label = "1/2 in";
}
: radio_button {
key = "eb1";
label = "3/4 in";
}
: radio_button {
key = "eb2";
label = "1 in";
}
: radio_button {
key = "eb3";
label = "1-1/2 in";
}

}
: column {
: radio_button {
key = "eb11";
label = "10 in";
}
: radio_button {
key = "eb12";
label = "12 in";
}
: radio_button {
key = "eb13";
label = "14 in";
}
: radio_button {
key = "eb14";
label = "16 in";
}
}
}
}
: boxed_row {
: button {
key = "accept";
label = " OKAY ";
is_default = true;
}
: button {
key = "cancel";
label = " Cancel ";
is_default = false;
is_cancel = true;
}
}
}

Code: [Select]
(defun c:templsp ()
(if (= PL_WEIGHT nil)(setq PL_WEIGHT 0.0))
(if(not (setq dcl_id (load_dialog "testcluster.dcl")))
(progn
(alert "The file could not be loaded.")
(exit)
)
(progn
(if (not (new_dialog "tcluster" dcl_id))
(progn
(alert "The DCL definition could not be found inside the DCL file.")
(exit))
(progn


(action_tile "eb0" "(setq PL_WEIGHT \"1.45\")(setq PL_UTILITY \"Single Hung 1/2 in\")")
(action_tile "eb1" "(setq PL_WEIGHT \"1.79\")(setq PL_UTILITY \"Single Hung 3/4 in\")")
(action_tile "eb2" "(setq PL_WEIGHT \"2.67\")(setq PL_UTILITY \"Single Hung 1 in\")")
(action_tile "eb3" "(setq PL_WEIGHT \"4.24\")(setq PL_UTILITY \"Single Hung 1-1/2 in\")")
(action_tile "eb11" "(setq PL_WEIGHT \"80.95\")(setq PL_UTILITY \"Single Hung 10 in\")")
(action_tile "eb12" "(setq PL_WEIGHT \"105.53\")(setq PL_UTILITY \"Single Hung 12 in\")")
(action_tile "eb13" "(setq PL_WEIGHT \"120.62\")(setq PL_UTILITY \"Single Hung 14 in\")")
(action_tile "eb14" "(setq PL_WEIGHT \"147.54\")(setq PL_UTILITY \"Single Hung 16 in\")")

(action_tile "accept" "(done_dialog 2)")
(action_tile "cancel" "(done_dialog 1)")

(setq ddiag(start_dialog))

(unload_dialog dcl_id)

(if (= ddiag 1)(princ "\n \n ...DCL_LSP Cancelled. \n "))
(if (= ddiag 2)
(progn
(princ "\n You test ")
)
)

)
)
))
(princ))


The error...
Quote
====== DCL semantic audit of testcluster.dcl ======

Warning in "tcluster". (widget type = cluster, key = "")
    Only radio buttons and spacers can be in radio clusters.

Warning in "tcluster". (widget type = radio_button, key = "eb0")
    A radio button\'s parent must be a radio cluster.

Warning in "tcluster". (widget type = radio_button, key = "eb1")
    A radio button\'s parent must be a radio cluster.

Warning in "tcluster". (widget type = radio_button, key = "eb2")
    A radio button\'s parent must be a radio cluster.

Warning in "tcluster". (widget type = radio_button, key = "eb3")
    A radio button\'s parent must be a radio cluster.

Warning in "tcluster". (widget type = radio_button, key = "eb11")
    A radio button\'s parent must be a radio cluster.

Warning in "tcluster". (widget type = radio_button, key = "eb12")
    A radio button\'s parent must be a radio cluster.

Warning in "tcluster". (widget type = radio_button, key = "eb13")
    A radio button\'s parent must be a radio cluster.

Warning in "tcluster". (widget type = radio_button, key = "eb14")
    A radio button\'s parent must be a radio cluster.
Title: Re: DCL radiobutton alignment
Post by: ymg on January 02, 2014, 09:08:14 PM
Remove the dcl setting at the head of your dcl file.

Then everything works fine.

Why?  Haven't got a cue.

I've done many test with the radio_clusters to no avail.
The error message that we see in your post is telling
that a radio button must have a cluster as a parent.

This implies that you cannot separate in 2 columns
unless you are ready to do some trick in the controlling Lisp.

For a good example of this see http://autodesk.lithium.com/t5/Visual-LISP-AutoLISP-and-General/DCL-Radio-Buttons-Divide-one-Radio-Column-into-Two-Radio-Columns/td-p/4696997 (http://autodesk.lithium.com/t5/Visual-LISP-AutoLISP-and-General/DCL-Radio-Buttons-Divide-one-Radio-Column-into-Two-Radio-Columns/td-p/4696997)

ymg
Title: Re: DCL radiobutton alignment
Post by: ymg on January 03, 2014, 11:43:43 AM
Try with this,

Code: [Select]
(defun c:tmplsp ()
     
  (if (not (setq dcl_id (load_dialog "testcluster.dcl")))
    (progn  (alert "The file could not be loaded.") (exit))
    (progn
      (if (not (new_dialog "tcluster" dcl_id))
        (progn
          (alert "The DCL definition could not be found inside the DCL file.")
          (exit)
        )
       
        (progn         
          (setq col0 '("eb0" "eb1" "eb2" "eb3")
                col1 '("eb10" "eb11" "eb12" "eb13")
                 zer '("0" "0" "0" "0")
          )     
          (defun togcol (button / rtn)
             (cond
                ((member button col1) (mapcar 'set_tile col0 zer))
                ((member button col0) (mapcar 'set_tile col1 zer))         
             )
             button
          )
          (action_tile "col0" "(setq choice (togcol (get_tile \"col0\")))")
          (action_tile "col1" "(setq choice (togcol (get_tile \"col1\")))") 
          (action_tile "accept" "(done_dialog 2)")
          (action_tile "cancel" "(done_dialog 1)")

          (setq ddiag (start_dialog))

          (unload_dialog dcl_id)

          (if (= ddiag 1) (princ "\n \n ...DCL_LSP Cancelled. \n "))
          (if (= ddiag 2)
             (cond
                 ((= choice  "eb0")  (setq PL_WEIGHT "0.56"     PL_UTILITY "Single Hung 1/2 in"))
                 ((= choice  "eb1")  (setq PL_WEIGHT "1.79"     PL_UTILITY "Single Hung 3/4 in"))
                 ((= choice  "eb2")  (setq PL_WEIGHT "2.67"     PL_UTILITY "Single Hung 1 in"))
                 ((= choice  "eb3")  (setq PL_WEIGHT "4.24"     PL_UTILITY "Single Hung 1-1/2 in"))
                 ((= choice  "eb10") (setq PL_WEIGHT "80.95"    PL_UTILITY "Single Hung 10 in"))
                 ((= choice  "eb11") (setq PL_WEIGHT "105.53"   PL_UTILITY "Single Hung 12 in"))
                 ((= choice  "eb12") (setq PL_WEIGHT "120.62"   PL_UTILITY "Single Hung 14 in"))
                 ((= choice  "eb13") (setq PL_WEIGHT "147.54"   PL_UTILITY "Single Hung 16 in"))
             )
          )
          (princ (strcat "\n You Selected: " pl_utility " , Weight: " pl_weight))

        )
      )
    )
  )
  (princ)
)

and the dcl:

Code: [Select]
tcluster : dialog { label = "2007 OPA - Mechancical Pipe - SCD 40  STD";     
           : row {   
                        : radio_column {
                             key = "col0";
                : radio_button {key = "eb0"; label = "1/2 in";  }
: radio_button {key = "eb1"; label = "3/4 in";  }
: radio_button {key = "eb2"; label = "1 in";    }
: radio_button {key = "eb3"; label = "1-1/2 in";}
}
: radio_column {
     key = "col1";
: radio_button {key = "eb10"; label = "10 in";   }
: radio_button {key = "eb11"; label = "12 in";   }
: radio_button {key = "eb12"; label = "14 in";   }
: radio_button {key = "eb13"; label = "16 in";   }
}
   }
   :boxed_row {
        ok_cancel;
   }     
         }
Title: Re: DCL radiobutton alignment
Post by: snownut2 on January 03, 2014, 03:19:06 PM
Whats wrong with this, works in both ACAD & BricsCAD without issue.

Code - Auto/Visual Lisp: [Select]
  1.  
  2.     : boxed_row {
  3.       label = "Select Force Main Pipe Size " ;
  4.        : radio_row {
  5.          : column {
  6.            : radio_button {
  7.              label = "1-1/4in. Plastic Pipe";
  8.              key = "125pp";
  9.            }
  10.            : radio_button {
  11.              label = "1-1/2in. Plastic Pipe";
  12.              key = "150pp";
  13.            }
  14.          }
  15.          : column {
  16.            : radio_button {
  17.              label = "2in. Plastic Pipe";
  18.              key = "200pp";
  19.            }
  20.            : radio_button {
  21.              label = "2-1/2in. Plastic Pipe";
  22.              key = "250pp";
  23.            }
  24.          }
  25.          : column {
  26.            : radio_button {
  27.              label = "3in. Plastic Pipe";
  28.              key = "300pp";
  29.            }
  30.          }
  31.        }
  32.      }
  33.  

You can have as many columns as you like, no trick LISP function needed.  I will typically use the same variable for the action_tile on radio buttons,

ie;

(action_tile "125pp" "(setq pipesize 1.25)")
(action_tile "150pp" "(setq pipesize 1.50)")

Pretty straight forward.

Using this method it does not matter what the $value of the button is, the last radio button selected sets the pipesize variable.  Eliminates the need for a cond function later to sort out the values, you can select all the radio buttons and the last one wins.....

Bruce
Title: Re: DCL radiobutton alignment
Post by: ymg on January 03, 2014, 04:41:13 PM
Snownut,

Do the button act as a single cluster ?

By that I mean say I select 2 in., then change my mind and select 3 in.
Does the 2in. button goes blank?

ymg
Title: Re: DCL radiobutton alignment
Post by: snownut2 on January 03, 2014, 04:47:42 PM
Yes, they act as a cluster, only one radio button will display as selected.  The one thing you need to look out for is regarding BricsCAD, they have what I would call a bug in their Radio Button feature, when a Dialog box opens the 1st button of the cluster appears as if it has been selected.  The way I work around this is to (setq pipesize) to the value of the 1st button prior to starting the dialog.  That way if the user just accepts (what appears to be a default value) all is well.
Title: Re: DCL radiobutton alignment
Post by: ymg on January 03, 2014, 04:56:31 PM
Bruce,

That would be good news, because every way I try I dont get it to act a single cluster.

ymg
Title: Re: DCL radiobutton alignment
Post by: ymg on January 03, 2014, 05:07:51 PM
Bruce,

Does not work as a single cluster in Autocad.

ymg
Title: Re: DCL radiobutton alignment
Post by: snownut2 on January 03, 2014, 05:30:25 PM
ymg,

I looked at my lsp code, it appears that I forced all other tiles to "0" ie (set_tile... "0")following the (setq....) on the (action_tile ) line.  I know this is not what you where looking for, but it is not impossible to do (make it appear that the other radio buttons are non-selected)

(action_tile "125pp" "(setq pipesize 1.25)(set_tile \"150pp\" \"0\")(set_tile \"200pp\" \"0\")(set_tile \"250pp\" \"0\")(set_tile \"300pp\" \"0\")")

Additionally it is still substantially quicker then creating multiple lines of code to accomplish the same task.

Sorry for the bum information.

Bruce
Title: Re: DCL radiobutton alignment
Post by: ymg on January 03, 2014, 05:57:53 PM
Bruce,

This is essentially the same method except that I go through a small routine to reset the button
and I divided them in column.

I do not think that there is any way around toggling the radio button through Lisp.

ymg
Title: Re: DCL radiobutton alignment
Post by: CAB on January 03, 2014, 06:18:42 PM
My take:
Code: [Select]
(defun c:tmplsp (/ choice)
  (defun ClearCol1() (mapcar '(lambda(x) (set_tile x "0")) '("eb10""eb11""eb12""eb13")))
  (defun ClearCol0() (mapcar '(lambda(x) (set_tile x "0")) '("eb0""eb1""eb2""eb3")))
  (if (not (setq dcl_id (load_dialog "testcluster.dcl")))
    (progn  (alert "The file could not be loaded.") (exit))
    (progn
      (if (not (new_dialog "tcluster" dcl_id))
        (alert "The DCL definition could not be found inside the DCL file.")
       
        (progn         
          (action_tile "col0" "(setq choice $value)(clearCol1)")
          (action_tile "col1" "(setq choice $value)(clearCol0)")
          (action_tile "accept" "(done_dialog 2)")
          (action_tile "cancel" "(done_dialog 1)")

          (setq ddiag (start_dialog))

          (unload_dialog dcl_id)

          (cond
            ((= ddiag 1) (princ "\n \n ...DCL_LSP Cancelled. \n "))
            ((/= ddiag 2)(princ "\n \n ...DCL_LSP Cancelled. \n "))
           
                 ((= choice  "eb0")  (setq PL_WEIGHT "0.56"     PL_UTILITY "Single Hung 1/2 in"))
                 ((= choice  "eb1")  (setq PL_WEIGHT "1.79"     PL_UTILITY "Single Hung 3/4 in"))
                 ((= choice  "eb2")  (setq PL_WEIGHT "2.67"     PL_UTILITY "Single Hung 1 in"))
                 ((= choice  "eb3")  (setq PL_WEIGHT "4.24"     PL_UTILITY "Single Hung 1-1/2 in"))
                 ((= choice  "eb10") (setq PL_WEIGHT "80.95"    PL_UTILITY "Single Hung 10 in"))
                 ((= choice  "eb11") (setq PL_WEIGHT "105.53"   PL_UTILITY "Single Hung 12 in"))
                 ((= choice  "eb12") (setq PL_WEIGHT "120.62"   PL_UTILITY "Single Hung 14 in"))
                 ((= choice  "eb13") (setq PL_WEIGHT "147.54"   PL_UTILITY "Single Hung 16 in"))
             )
          (if choice (princ (strcat "\n You Selected: " pl_utility " , Weight: " pl_weight)))

        )
      )
    )
  )
  (princ)
)
Code: [Select]
tcluster : dialog { label = "2007 OPA - Mechancical Pipe - SCD 40  STD";     
                  : row {   
                        : radio_column { key = "col0";
                        : radio_button {key = "eb0"; label = "1/2 in";  }
                : radio_button {key = "eb1"; label = "3/4 in";  }
                : radio_button {key = "eb2"; label = "1 in";    }
                : radio_button {key = "eb3"; label = "1-1/2 in";}
                }
                        : radio_column { key = "col1";
                : radio_button {key = "eb10"; label = "10 in";   }
                : radio_button {key = "eb11"; label = "12 in";   }
                : radio_button {key = "eb12"; label = "14 in";   }
                : radio_button {key = "eb13"; label = "16 in";   }
                }
           }
           :boxed_row {
                ok_cancel;
           }     
         }
Title: Re: DCL radiobutton alignment
Post by: ymg on January 03, 2014, 07:57:12 PM
CAB,

This is cleaner and thus clearer.

But we still need to toggle the radio button.

I've tried with the radio_clusters describe by Keith but to no avail.

ymg
Title: Re: DCL radiobutton alignment
Post by: snownut2 on January 03, 2014, 08:17:54 PM
The "clearcol.." functions clear all radio buttons..

how about this..

Code - Auto/Visual Lisp: [Select]
  1. (action_tile "col0" "(setq choice $value)(clearCol1)(set_tile choice \"1\")")
  2.  

Haven't tried it.

Title: Re: DCL radiobutton alignment
Post by: ymg on January 04, 2014, 02:28:47 AM
Bruce,

Code: [Select]
(defun clrbut (choice)
     (setq cluster '("eb0" "eb1" "eb2" "eb3" "eb10" "eb11" "eb12" "eb13"))           
     (mapcar '(lambda(x) (set_tile x "0")) cluster)
     (set_tile choice "1")
)         
(action_tile "col0" "(clrbut (setq choice $value))")
(action_tile "col1" "(clrbut (setq choice $value))") 

Would work!
Title: Re: DCL radiobutton alignment
Post by: snownut2 on January 04, 2014, 08:14:18 AM
ymg,

Good to hear, it is also interesting how "key" for the columns works.  I had read some time ago that you could assign a "key" to columns & rows but until now I wasn't sure how to apply it. 

This code seems about as concise as it can be, just need to localize the "cluster" variable in the clrbut function, or it could be eliminated altogether by replacing the cluster variable in the mapcar line with the actual list.

Bruce
Title: Re: DCL radiobutton alignment
Post by: hmspe on January 04, 2014, 10:08:27 AM
I don't know if this will add anything to the discussion, but attached is a function I put together several years ago that uses a multi-column radio box and which calculates available fault current for electrical circuits.  If you select more than one set of conductors in the dialog it deactivates one column in the multi-column radio box.  If you select a point in open space in the drawing as the first step you will need to enter enter all required values for the OK button to be enabled.  If you click on the "F1" of an existing calculation it will fill the boxes from the data in the existing calculation.  I checked this in Bricscad 14.

I have converted this to OpenDCL so I no longer use this version.  OpenDCL provides much better formatting capability.
Title: Re: DCL radiobutton alignment
Post by: ymg on January 04, 2014, 11:30:54 AM
Yet another,

Code: [Select]
(defun clrbut (col / but cluster)
       (setq cluster '("col0" "col1"))           
       (foreach cl (vl-remove col cluster)
            (if (setq but (get_tile cl))(set_tile but "0"))             
      )

(action_tile "col0" "(setq choice $value)(clrbut \"col0\")")
(action_tile "col1" "(setq choice $value)(clrbut \"col1\")") 
Title: Re: DCL radiobutton alignment
Post by: ymg on January 04, 2014, 01:58:13 PM
hmspe,

Could not run your routine as block "fault-CUAL.dwg" is missing.

ymg
Title: Re: DCL radiobutton alignment
Post by: CAB on January 04, 2014, 03:05:38 PM
One more:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:tmplsp (/ choice)
  2.   (defun ClearCol(key)
  3.     (mapcar '(lambda(x) (set_tile x "0")) '("eb0""eb1""eb2""eb3""eb10""eb11""eb12""eb13"))
  4.     (set_tile key "1")
  5.     )
  6.   (if (not (setq dcl_id (load_dialog "testcluster.dcl")))
  7.     (progn  (alert "The file could not be loaded.") (exit))
  8.     (progn
  9.       (if (not (new_dialog "tcluster" dcl_id))
  10.         (alert "The DCL definition could not be found inside the DCL file.")
  11.        
  12.         (progn          
  13.           (action_tile "col0" "(setq choice $value)(clearCol $value)")
  14.           (action_tile "col1" "(setq choice $value)(clearCol $value)")
  15.           (action_tile "accept" "(done_dialog 2)")
  16.           (action_tile "cancel" "(done_dialog 1)")
  17.  
  18.           (setq ddiag (start_dialog))
  19.           (unload_dialog dcl_id)
  20.           (cond
  21.             ((= ddiag 1) (princ "\n \n ...DCL_LSP Cancelled. \n "))
  22.             ((/= ddiag 2)(princ "\n \n ...DCL_LSP Cancelled. \n "))
  23.             ((setq data (assoc choice
  24.                '(("eb0"  "0.56"   "Single Hung 1/2 in")
  25.                  ("eb1"  "1.79"   "Single Hung 3/4 in")
  26.                  ("eb2"  "2.67"   "Single Hung 1 in")
  27.                  ("eb3"  "4.24"   "Single Hung 1-1/2 in")
  28.                  ("eb10" "80.95"  "Single Hung 10 in")
  29.                  ("eb11" "105.53" "Single Hung 12 in")
  30.                  ("eb12" "120.62" "Single Hung 14 in")
  31.                  ("eb13" "147.54" "Single Hung 16 in")
  32.                  )))
  33.               (setq pl_utility (cadr data) pl_weight (caddr data))
  34.                )
  35.              )
  36.           (if data
  37.             (princ (strcat "\n You Selected: " pl_utility " , Weight: " pl_weight))
  38.             (princ "\nNo data on file.")
  39.           )
  40.  
  41.         )
  42.       )
  43.     )
  44.   )
  45.   (princ)
  46. )

Code: [Select]
tcluster : dialog { label = "2007 OPA - Mechancical Pipe - SCD 40  STD";     
  : row {
     : radio_column { key= "col0";
       : radio_button {key = "eb0"; label = "1/2 in";  }
       : radio_button {key = "eb1"; label = "3/4 in";  }
       : radio_button {key = "eb2"; label = "1 in";    }
       : radio_button {key = "eb3"; label = "1-1/2 in";}
       }
     : radio_column { key= "col1";
       : radio_button {key = "eb10"; label = "10 in";   }
       : radio_button {key = "eb11"; label = "12 in";   }
       : radio_button {key = "eb12"; label = "14 in";   }
       : radio_button {key = "eb13"; label = "16 in";   }
       }
  }
  :boxed_row { ok_cancel; }     
}
Title: Re: DCL radiobutton alignment
Post by: snownut2 on January 04, 2014, 03:17:48 PM
Very nice CAB, glad to see you used the "assoc" function to sort out the value for the appropriate radio button, that is my choice also...I have been getting comfortable with list and replacing "cond" statements with list functions where practical. 

Although I would have used nth 1 & nth 2 instead of cadr & caddr, just personal preference though.
Title: Re: DCL radiobutton alignment
Post by: ymg on January 04, 2014, 03:31:35 PM
Agree assoc list is the way to go.

Yet another one for the clearing function.

Code: [Select]
(defun clrbut (k / b)
   (mapcar '(lambda(x) (if (setq b (get_tile x ))(set_tile b "0"))) (vl-remove k '("col0" "col1")))             

(action_tile "col0" "(setq choice $value)(clrbut $key)")
(action_tile "col1" "(setq choice $value)(clrbut $key)") 

This way we do not iterate through all the buttons, but simply reset the single button that is ON
in a given cluster.

ymg
Title: Re: DCL radiobutton alignment
Post by: Stefan on January 04, 2014, 04:22:14 PM
Yet another one for the clearing function...

Or this, without clrbut
Code - Auto/Visual Lisp: [Select]
  1. (foreach x '("col0" "col1")
  2.   (action_tile x "(if (/= $value choice) (set_tile choice \"0\"))
  3.                  (setq choice $value)")
  4. )
Title: Re: DCL radiobutton alignment
Post by: ymg on January 04, 2014, 04:44:49 PM
stefan,

Probably the most concise and clear one.

Quote
(foreach x '("col0" "col1")
   (action_tile x "(if (/= $value choice) (set_tile choice \"0\")) (setq choice $value)")
)

The clusters are defined in the foreach statement,
and there is no need for multple action_tile.

Maybe:
Code: [Select]
(action_tile x "(if choice (set_tile choice \"0\")) (setq choice $value)"))
Little clearer and concise.

ymg
Title: Re: DCL radiobutton alignment
Post by: Stefan on January 04, 2014, 06:11:26 PM

Maybe:
Code: [Select]
(action_tile x "(if choice (set_tile choice \"0\")) (setq choice $value)"))
Little clearer and concise.

ymg
In this case, the button will be deselected if you click twice on it.
That's the reason I used (/= $value choice).

Anyway, I think the reason of using multiple columns of radio-buttons only in a dialog box is the size of dialog.
A good alternative is dosLib.
If the goal is to pick an item in a list, dos_popupmenu is the best choice.
If the list is huge enough to make it unreadable (using dosLib) then it is more uncomfortable to read it in a dialog box.
Code - Auto/Visual Lisp: [Select]
  1. (setq l '("1/2 in" "3/4 in" "1 in" "1-1/2 in" "10 in" "12 in" "14 in" "16 in"))
  2.   (setq x (dos_popupmenu l))
  3.   (nth x l)
  4.   )
  5.  
Title: Re: DCL radiobutton alignment
Post by: ymg on January 04, 2014, 06:16:57 PM
Here's the final take hopefully!

Code - Auto/Visual Lisp: [Select]
  1. (defun c:testcluster (/ choice data dcl_id ddiag)      
  2.   (if (not (setq dcl_id (load_dialog "testcluster.dcl")))
  3.     (progn  (alert "The file could not be loaded.") (exit))
  4.   )
  5.   (if (not (new_dialog "tcluster" dcl_id))
  6.      (progn (alert "The DCL definition could not be found inside the DCL file.") (exit))
  7.   )      
  8.   (foreach x '("col0" "col1")
  9.      (action_tile x "(if choice (set_tile choice \"0\")) (setq choice $value)")
  10.   )
  11.   (action_tile "accept" "(done_dialog 1)")
  12.   (action_tile "cancel" "(done_dialog 0)")
  13.  
  14.   (setq ddiag (start_dialog))
  15.   (unload_dialog dcl_id)
  16.   (cond
  17.      ((= ddiag 0) (princ "\n \n ...DCL_LSP Cancelled. \n "              ))
  18.      ((not choice)(princ "\n \n ...No Selection. \n "                   ))
  19.      ((setq data (assoc choice '(("eb0"  "0.56"   "Single Hung 1/2 in"  )
  20.                                  ("eb1"  "1.79"   "Single Hung 3/4 in"  )
  21.                                  ("eb2"  "2.67"   "Single Hung 1 in"    )
  22.                                  ("eb3"  "4.24"   "Single Hung 1-1/2 in")
  23.                                  ("eb10" "80.95"  "Single Hung 10 in"   )
  24.                                  ("eb11" "105.53" "Single Hung 12 in"   )
  25.                                  ("eb12" "120.62" "Single Hung 14 in"   )
  26.                                  ("eb13" "147.54" "Single Hung 16 in"   ))
  27.                  )
  28.       )
  29.       (princ (strcat "\nYou Selected: " (caddr data) " , Weight: " (cadr data)))
  30.      )
  31.   )              
  32.   (princ)
  33. )
  34.  

Here is the DCL:

Code - Auto/Visual Lisp: [Select]
  1. tcluster : dialog { label = "2007 OPA - Mechancical Pipe - SCD 40  STD";      
  2.                    : row {
  3.                       : radio_column {
  4.                              key = "col0";
  5.                            
  6.                                 : radio_button {key = "eb0"; label = "1/2 in";  }
  7.                                 : radio_button {key = "eb1"; label = "3/4 in";  }
  8.                                 : radio_button {key = "eb2"; label = "1 in";    }
  9.                                 : radio_button {key = "eb3"; label = "1-1/2 in";}
  10.                         }
  11.                         : radio_column {
  12.                              key = "col1";
  13.                              
  14.                                 : radio_button {key = "eb10"; label = "10 in";   }
  15.                                 : radio_button {key = "eb11"; label = "12 in";   }
  16.                                 : radio_button {key = "eb12"; label = "14 in";   }
  17.                                 : radio_button {key = "eb13"; label = "16 in";   }
  18.                         }                              
  19.                    }
  20.                    :boxed_row {  ok_cancel; }    
  21.          }
  22.  

Not so bad for something designed by a committee  :laugh:

ymg
Title: Re: DCL radiobutton alignment
Post by: ymg on January 04, 2014, 06:35:58 PM
stefan,

I agree with the Doslib thingie.

However the thread was mainly about having Radio Button Clusters in many rows or columns.

This is a recurring theme, and I see in various Forum peoples claiming that you don't need
any special Lisp to handle them.

Hope the issue is put to sleep,

WE DO NEED TO PROCESS THE CLUSTERS!

ymg
Title: Re: DCL radiobutton alignment
Post by: Lee Mac on January 04, 2014, 06:45:10 PM
Or this, without clrbut
Code - Auto/Visual Lisp: [Select]
  1. (foreach x '("col0" "col1")
  2.   (action_tile x "(if (/= $value choice) (set_tile choice \"0\"))
  3.                  (setq choice $value)")
  4. )

Nicely done Stefan  :-)



Here's the final take hopefully!

This may be cleaner:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:tcluster ( / dch itm )
  2.     (if (and (< 0 (setq dch (load_dialog "tcluster.dcl")))
  3.              (new_dialog "tcluster" dch)
  4.         )
  5.         (progn
  6.             (set_tile (cond (tcl:sel) ((setq tcl:sel "0"))) "1")
  7.             (foreach c '("c0" "c1")
  8.                 (action_tile c
  9.                     (vl-prin1-to-string
  10.                        '(if (/= $value tcl:sel)
  11.                             (progn (set_tile tcl:sel "0") (setq tcl:sel $value))
  12.                         )
  13.                     )
  14.                 )
  15.             )
  16.             (if (= 1 (start_dialog))
  17.                 (progn
  18.                     (setq itm
  19.                         (nth (atoi tcl:sel)
  20.                            '(
  21.                                 ("0.56"   "Single Hung 1/2 in"  )
  22.                                 ("1.79"   "Single Hung 3/4 in"  )
  23.                                 ("2.67"   "Single Hung 1 in"    )
  24.                                 ("4.24"   "Single Hung 1-1/2 in")
  25.                                 ("80.95"  "Single Hung 10 in"   )
  26.                                 ("105.53" "Single Hung 12 in"   )
  27.                                 ("120.62" "Single Hung 14 in"   )
  28.                                 ("147.54" "Single Hung 16 in"   )
  29.                             )
  30.                         )
  31.                     )
  32.                     (princ (strcat "\nYou selected: " (cadr itm) ", weight: " (car itm)))
  33.                 )
  34.             )
  35.         )
  36.     )
  37.     (if (< 0 dch) (unload_dialog dch))
  38.     (princ)
  39. )

Save the following as tcluster.dcl:
Code - DCL: [Select]
  1. tcluster : dialog
  2. {
  3.     spacer; label = "Test Cluster";
  4.     : row
  5.     {
  6.         fixed_width = true;
  7.         alignment = centered;
  8.         : radio_column
  9.         {
  10.             key= "c0";
  11.             : radio_button { key = "0"; label = "1/2 in";  }
  12.             : radio_button { key = "1"; label = "3/4 in";  }
  13.             : radio_button { key = "2"; label = "1 in";    }
  14.             : radio_button { key = "3"; label = "1-1/2 in";}
  15.         }
  16.         : radio_column
  17.         {
  18.             key= "c1";
  19.             fixed_width = true;
  20.             : radio_button { key = "4"; label = "10 in"; }
  21.             : radio_button { key = "5"; label = "12 in"; }
  22.             : radio_button { key = "6"; label = "14 in"; }
  23.             : radio_button { key = "7"; label = "16 in"; }
  24.         }
  25.     }
  26.     spacer; ok_cancel;
  27. }

I don't like to use (exit) or (quit) in code if I can avoid it - also, as far as I know load_dialog doesn't return nil, only a negative or zero value on failure.

The action_tile statements for the accept & cancel tiles are redundant since these are predefined.

The above code will also remember the last selection since tcl:sel is global.
Title: Re: DCL radiobutton alignment
Post by: ymg on January 04, 2014, 08:50:24 PM
Lee,

Didn't know about tcl:sel, so I learned something.

Don't much like doing the processing with the dialog ON,
so I prefer (exit).

I would get rid of the progn and move the printing of results outside.

Code - Auto/Visual Lisp: [Select]
  1. (if (= 1 (start_dialog))
  2.                   (setq itm
  3.                        (nth (atoi tcl:sel)
  4.                            '(("0.56"   "Single Hung 1/2 in"  )
  5.                              ("1.79"   "Single Hung 3/4 in"  )
  6.                              ("2.67"   "Single Hung 1 in"    )
  7.                              ("4.24"   "Single Hung 1-1/2 in")
  8.                              ("80.95"  "Single Hung 10 in"   )
  9.                              ("105.53" "Single Hung 12 in"   )
  10.                              ("120.62" "Single Hung 14 in"   )
  11.                              ("147.54" "Single Hung 16 in"   ))
  12.                        )
  13.                   )                
  14.             )
  15.         )
  16.     )
  17.     (if (< 0 dch) (unload_dialog dch))  
  18.     (if itm (princ (strcat "\nYou selected: " (cadr itm) ", weight: " (car itm))))
  19.     (princ)
  20. )
  21.  

But it is all a matter of style.

ymg
Title: Re: DCL radiobutton alignment
Post by: Lee Mac on January 05, 2014, 05:15:25 AM
Don't much like doing the processing with the dialog ON, so I prefer (exit).

What processing?

The programs operate in much the same way, with the evaluation ceasing if the criteria for the dialog loading successfully is not met. Only, at this point, your code will force an error using (exit), whereas my code will exit cleanly without error - I see no argument for using (exit).

I would get rid of the progn and move the printing of results outside.

Why? I see no reason to do this - on the contrary, this adds redundancy to the code as there is no need to test whether itm is defined if the princ expression is included within the 'then' argument for the if function.
Title: Re: DCL radiobutton alignment
Post by: CAB on January 05, 2014, 07:26:37 AM
Ditto, I haven't used EXIT in years.  :)
Title: Re: DCL radiobutton alignment
Post by: snownut2 on January 05, 2014, 07:37:01 AM
ymg,

How do you build calculator type DCL's if you can not process while DCL is active ? (or nested drop down selection sets)
Title: Re: DCL radiobutton alignment
Post by: hmspe on January 05, 2014, 09:14:16 AM
hmspe,

Could not run your routine as block "fault-CUAL.dwg" is missing.

ymg

My error.  The file is attached. 



Title: Re: DCL radiobutton alignment
Post by: Stefan on January 05, 2014, 10:44:12 AM
Nicely done Stefan  :-)
Thank you Lee

Here is a generic function for a max 10x10 radio cluster, including dcl generator.
Note this is a demo function. The original one contains a test for list's validity and the option to accept argument list as a single dimension list, in which case a single column appears in dialog box.
Returns the label of selected tile.
Code - Auto/Visual Lisp: [Select]
  1. (defun radio_columns (title label l / file dcl i j dcl_id r)
  2.   ;; open dcl file
  3.   (setq file (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".dcl")
  4.         dcl  (open file "w")
  5.   )
  6.   ;; write dialog file
  7.   (write-line (strcat "radiobuttoncol : dialog { label = \"" title "\";") dcl)
  8.   (write-line (strcat ": boxed_row { label = \""
  9.                       label
  10.                       "\"; children_fixed_height = true; children_alignment = \"Top\";")
  11.               dcl)
  12.   (setq i 0)
  13.   (foreach col l
  14.     (setq j 0)
  15.     (write-line (strcat ": radio_column { key = \"" (itoa i) "\";") dcl)
  16.     (foreach row col
  17.       (write-line (strcat ": radio_button { label = \"" row "\"; key = \"" (itoa i) (itoa j) "\";}") dcl)
  18.       (setq j (1+ j))
  19.     )
  20.     (write-line "}" dcl)
  21.     (setq i (1+ i))
  22.   )
  23.   (write-line "}ok_cancel;}" dcl)
  24.   (close dcl)
  25.   ;;check global var *retb* if it's value matching list's dimension
  26.   ;;*retb* is a 2 chars string. First is column number, second is row number, 0-based index
  27.   ;;limits dialog to max 10/10 cols/rows
  28.   (or (and *retb*
  29.            (< (atoi (substr *retb* 1 1)) (length l))
  30.            (< (atoi (substr *retb* 2 1)) (length (nth (atoi (substr *retb* 1 1)) l)))
  31.       )
  32.       (setq *retb* "00")
  33.   )
  34.   ;start dialog
  35.   (if
  36.     (setq dcl_id (load_dialog file))
  37.      (if
  38.        (new_dialog "radiobuttoncol" dcl_id)
  39.         (progn
  40.           (repeat i (action_tile
  41.                       (itoa (setq i (1- i)))
  42.                       "(if (/= *retb* $value) (set_tile *retb* \"0\")) (setq *retb* $value)"
  43.                     )
  44.           )
  45.           (set_tile *retb* "1")
  46.           (setq r (start_dialog))
  47.           (unload_dialog dcl_id)
  48.         )
  49.      )
  50.   )
  51.   (if (findfile file) (vl-file-delete file))
  52.   (if (= r 1) (nth (atoi (substr *retb* 2 1)) (nth (atoi (substr *retb* 1 1)) l)))
  53. )
  54.  
  55.  
  56. (defun c:test ( / l tmp)
  57.   (repeat (1+ (rem (dos_random) 10))
  58.     (setq tmp nil)
  59.     (repeat (1+ (rem (dos_random) 10))
  60.       (setq tmp (cons (strcat (chr (+ 65 (rem (dos_random) 26))) (chr (+ 65 (rem (dos_random) 26)))) tmp))
  61.       )
  62.     (setq l (cons tmp l))
  63.     )
  64.   (radio_columns "Dialog Title" "Box Label" l)
  65.   )  
Title: Re: DCL radiobutton alignment
Post by: ymg on January 05, 2014, 11:50:15 AM
hmspe,

What tou are doing is defining a function "set_radios" and running it.

Although you are doing the action from the dialog box, it is essentially
the same as what we were doing with clrbut when resetting all buttons.

The way proposed is to use the keys of the radio-columns or radio-rows
and reset only the single tile that is ON in any rows or columns.

Stefan's way is most elegant, because it does away with the function call
and keeps everything in a logical way, where it belongs.

Whereby with the function, you either defined the clusters in the function or
you would need to pass it as a parameter.  This makes for spaghetti code.

It's a nice calculator you have there, although you could have written it
much more concisely. 

Looks like you like to type  :-)

ymg
Title: Re: DCL radiobutton alignment
Post by: hmspe on January 05, 2014, 09:30:13 PM

Looks like you like to type  :-)

Not really.  This code is around 10 years old.  I think I've gotten a bit better at coding since then.  That said, I'm an engineer that occasionally writes code to automate my work, and trying to remember how elegant/compact/fast constructs work when you don't write code regularly is a challenge.  I'm more concerned with being able to maintain my code in the future.  Simple structure may not be as efficient but it is easy to maintain.  In this case the speed of simple code is more than adequate.  At a previous job where I wrote code for testing jet engines for use with 6MHz PC AT computers efficiency came first.  With a 3GHZ+ computer and writing for internal use only I'm only worried about "fast enough".

My intention was to provide a real world example that has been used in production.  The ODCL version is much nicer.

Title: Re: DCL radiobutton alignment
Post by: TheyCallMeJohn on January 09, 2014, 07:22:37 PM
Thank you guys so much! I didn't realize this would turn into such a discussion. I would have been back sooner but I had bad case of the flu.

Like Hmspe, I am an engineer that occasionally writes code to remove what I see as inefficiencies. You all are way more experienced than I am so 9/10 of this is way over my head but I shall strive to figure out how to implement it into the code I already have written. The portion I posted is only a small simplified part of my larger program. Due to varying list lengths, I had write a lisp to write lisp and  DCL "On the Fly" (as Kenny with Afralisp put it),

I greatly appreciate all your help.

Title: Re: DCL radiobutton alignment
Post by: ymg on January 10, 2014, 01:27:56 PM
TheyCallMeJohn,

Was a long discussion, but out of it came Stefan's way which is very nice!!

And I see you sorted your problem.

ymg