Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DCL, lisp Help - Radio Buttons Causing a Crash.

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
RockyBrown4134
787 Views, 8 Replies

DCL, lisp Help - Radio Buttons Causing a Crash.

I am having a problem getting two Radio Buttons to work correctly. When I  run the program. the Dialog displays fine. I can Choose either "Elevation" or "Plan" under the views section. If i want to select the other instead of the first, the dialog crashes. What could cause the crash? I must be overlooking something. 

 

All suggestions are welcome. Any improvements are welcome.

 

I have included both files. The main body of the lisp file is incomplete, as far as  the function goes. I have not coded that in yet.

 

Thanks.

 

 

Here is the Code:

 

 

I have this code in my DCL file:

		:radio_column {
			label = "Views";
			fixed_width = true;
			fixed_height = true;
			alignment = top;
			: radio_button {
				label ="&Elevation";
				key = "hrelvn";
			}
			: radio_button {
				label ="&Plan";
				key = "hrpln";
			}
		}//end radio column


This is the code in my .lsp for the action tile, under the dialog box:

	(action_tile "hrelvn"
		"(hrelvn)")

	(action_tile "hrpln"
		"(hrpln)")

This is the code in my .lsp for three sub-routines:

(defun hrpln ()
	(progn
	(setq hrpln "T")
	(setq hrelvn "F")
	);end progn
);end defun
;
(defun hrelvn ()
	(progn
	(setq hrpln "F")
	(setq hrelvn "T")
	);end progn
);end defun

(defun resethrvars ()
	(progn
        (setq os (getvar "osmode"))
	(setq MATL nil)
	(setq PC_MK_RQD nil)
	(setq PC_MK nil)
	(setq hrpln nil)
	(setq hrelvn nil)
	(setq GAP_LT nil)
	(setq GAP_RT nil)
	(setq WING_LT nil)
	(setq WING_RT nil)
	(setq WINGLT nil)
	(setq WINGRT nil)
	(setq hrtype nil)
	(setq chk1 "N")
	(setq chk2 "N")
	(setq chk3 "N")
	);end progn
);end defun


This is the main Body of the code:

(defun C:HR2014 (/ os chk1 chk2 chk3 MATL)
	(setvar "cmdecho" 0)
	(setq os (getvar "osmode"))
	(setq olderr *error*   
         	     *error* CHGTERR)
	(resethrvars)
	(while
	   (or
		(= chk1 "N")(= chk2 "N")(= chk3 "N")
	   );end or
	(hrdialog)
		(if
		   (= MATL nil)
		   (alert "Must Select Material Type!")
		   (setq chk1 "OK")
		);end if

		(if
		   (= PC_MK_RQD nil)
		   (alert "Must Select Piece Mark Type!")
		   (setq chk2 "OK")
		);end if
		(if
		   (or 
			(/= hrelvn "T")(/= hrpln "T")
		   );end and
		   (alert "Must Select View!")
		   (setq chk3 "OK")
		);end if
	);end While
	(hrdist)
);end defun

 dcl1.jpg

 

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
8 REPLIES 8
Message 2 of 9
paullimapa
in reply to: RockyBrown4134

Your (resethrvars) nullifies those functions:	(setq hrpln nil)	(setq hrelvn nil)

So just change those function calls to a different name like (defun hrpln- .... and (defun hrelvn- .... see attached revised lsp.

 

 

 

AOL @ Exchange App Store         DDSetup @ Exchange App Store

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 9
RockyBrown4134
in reply to: paullimapa

Thanks Paul. That did it.
If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
Message 4 of 9
paullimapa
in reply to: RockyBrown4134

You are very welcome.

 

 

AOL @ Exchange App Store         DDSetup @ Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 9
scot-65
in reply to: RockyBrown4134

>>

>> Any improvements are welcome.

>>

 

As an alternative to the method you developed:

 

- Delete the action_tile for each radio_button (ALL radio buttons except those that will toggle mode_tile).

 

- Assign a key for the [EACH] radio_column (or radio_row, boxed_radio_column, etc.).

 

- In the action_tile "accept" area, make a call to a subroutine to record all tiles' current status:

 

 (action_tile "accept" "(HANDRAILS_GET)(done_dialog 1)").

 

 

The handrails_get subroutine is designed to take a "snapshot" of the current geometry of the dialog when OK is pressed.

This is where you will get the value of that radio_column. For your example it will return either "hrelvn" or "hrpln".

Repeat for all tiles and save as a list.

 

To store this list, either set it as a local variable (setq), session variable [Gremlin] (with a "USER_" prefix), or a dictionary

item (permanent to the file itself) using VLAX-LDATA-PUT. Registry, write to file, and SETCFG are other methods of

storage.

 

You will find that coding will be significantly less when developing the dialog, and information from the dialog is

all in one place, as a single variable - to be accessed via NTH after the dialog is closed.

 

(defun HANDRAILS_GET ()

 (setq USER_HANDRAIL (list

  (get_tile "Handrail")

  (get_tile "Material")

  (get_tile "Views")

  (get_tile "Piece")

  etc.

 ))

);end HANDRAILS_GET

 

Using example above and your notation:

 (if (= (nth 2 USER_HANDRAIL) "hrelev")... will return "hrelev" or "hrpln".

For more than two radio buttons, construct a COND and go from there.

 

FWIW, I did not develop programs using LIST as storage until I started doing DCL. To me, these two go hand-in-hand.

 

 

Hope this helps.

 


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


Message 6 of 9
RockyBrown4134
in reply to: scot-65

Hmmmmmm. Interesting. I'll try this when i get a chance.

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
Message 7 of 9
RockyBrown4134
in reply to: scot-65


@scot-65 wrote:

 

- Assign a key for the [EACH] radio_column (or radio_row, boxed_radio_column, etc.).

 

 


I just got back to working with this. I am not sure if I understand correctly. Is this what You mean? If not, would you please give an example.

 

 

                : row {

                : column {

                                :radio_column {

                                                label = "Handrails";

                                                Key = "Handrails";

                                                fixed_width = true;

                                                fixed_height = true;

                                                alignment = top;

                                                : radio_button {

                                                                label ="&HR Wing RT";

                                                                key = "HR-SWR";

                                                }

                                                : radio_button {

                                                                label ="&HR Wing LT";

                                                                key = "HR-SWL";

                                                }

                                                : radio_button {

                                                                label ="&HR Single";

                                                                key = "HR-S";

                                                }

                                                : radio_button {

                                                                label ="&HR Single - Wing RT";

                                                                key = "HR-S-SWR";

                                                }

                                                : radio_button {

                                                                label ="&HR Single - Wing LT";

                                                                key = "HR-S-SWL";

                                                }

                                                : radio_button {

                                                                label ="&HR Single - Double Wing";

                                                                key = "HR-S-DW";

                                                }

                                                : radio_button {

                                                                label ="&HR Double";

                                                                key = "HR-D";

                                                }

                                                : radio_button {

                                                                label ="&HR DOUBLE - Wing RT";

                                                                key = "HR-D-SWR";

                                                }

                                                : radio_button {

                                                                label ="&HR DOUBLE - Wing LT";

                                                                key = "HR-D-SWL";

                                                }

                                                : radio_button {

                                                                label ="&HR Double - Double Wing";

                                                                key = "HR-D-DW";

                               }

                                }//end radio column

                                }//end column

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
Message 8 of 9
RockyBrown4134
in reply to: scot-65


scot-65 wrote:

 

- In the action_tile "accept" area, make a call to a subroutine to record all tiles' current status:

 


I have remarked ou the tiles you indiaded and here rere is the line I have tried for the "Accept" tile.  

 

(action_tile "accept" "(HANDRAILS_GET)(savevars)(done_dialog 1)")

 

Where HANDRAILS_GET ia as you difind it:

 

(defun HANDRAILS_GET ()

 (setq USER_HANDRAIL (list

  (get_tile "Handrail")

  (get_tile "Material")

  (get_tile "Views")

  (get_tile "Piece")

  etc.

 ))

);end HANDRAILS_GET

 

When I run !USER_HANDRAIL, I get a return of (nil "mat-stl" "hrelvn" nil). Tiles two and three seem to be working, but a nil response to tiles one and fout indicates that I am doing something wrong, I think.

 

I must be overlooking something simple.

 

Any suggestion?

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
Message 9 of 9
scot-65
in reply to: RockyBrown4134

Your first post on 8-21-2014 looks good.

Tile names are case sensitive.
Your key="Handrails" and you (get_tile "Handrail").
???

In general, I use a consistent notation for all keys regardless
of what the program is about. At this point it does not matter
as maybe in the future I will take snippets/blocks of DCL code
from existing and create a brand new dialog.

The structure can be described as follows:
Header section: "Tex000".
Next section: [3-char tile name] plus "100".
Next section: [3-char tile name] plus "200".
Sections are usually bound to rows, columns, boxed columns, etc.
From within a section (for instance "Row300") I will keep
the first number only and go from there (hard to explain).
:row {key="Row300"
:text_part {key="Tex301"}
:toggle {key="Tog301"}
:text_part {key="Tex302"}
:toggle {key="Tog302"}
:edit_box {key="Edi301"}
}//row

There can be up to 10 sections using this type of notation with
a minimum 99 members inside. But, that's just me...

For radio buttons:
radio_column = Rad400
radio_button = Rad401
...
radio_button = Rad499
//radio_column

It also helps to print out a screen capture and actually map
the sections and keys by writing directly onto the printout.
But, that's just me...

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


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost