I'm running into an error, and I don't know why it exists. I'm trying to build a dialog box for users to update all of the title blocks and revisions for a job of their choosing. I have a rough layout put together, but when I go to run it, I get the following error message.
Continuing past this point just causes the application to crash. Adding ok_cancel ;
to the end stops the dialog box from crashing, but now I have two additional button that aren't clearly defined for the user and are redundant in purpose.
How do I make the dialog box work without adding any additional buttons?
Lisp Code
(setq *sDCLPath* "[Stored directory]"); Either use "\\" or "/" between folder names
(setq *sName01* "[File's name]")
;; Starts the dialog box for user input
(defun C:Test01 (/ sPathAndName dclFile vModule)
;; File Exists
(setq sPathAndName (findfile (strcat *sDCLPath* "\\" *sName01* ".dcl")))
(if (not sPathAndName)(progn
(princ "\nError: The DCL file was not found.\n")
(princ "\nPath and name: ")(princ sPathAndName)(terpri)
(exit)
));if<-progn
;; DCL File
(setq dclFile (load_dialog sPathAndName))
(if (>= 0 dclFile)(progn
(princ "\nError: DCL file cannot be loaded.\n")
(exit)
));if<-progn
(new_dialog "TitleRevUpdate" dclFile "(done_dialog 0)" '(-1 -1))
(start_dialog)
(unload_dialog dclFile)
(gc)
(princ)
);C:Test01
DCL Code
TitleRevUpdate : dialog {
key = "Title" ;
label = "Update Title Block and Revision" ;
// Title
: boxed_column {
key = "Column_TitleBoxes" ;
label = "Title" ;
// Client
: boxed_column {
key = "Client_Box" ;
label = "Client" ;
: row { // Row 01 - Name
key = "Row_Client_Name" ;
: text {
key = "txt_Client_Name" ;
label = "Client's Name" ;
}// text
: edit_box {
key = "edbx_Client_Name" ;
}// edit_box
} //row
: row { // Row 02 - Location
key = "Row_Client_Loc" ;
: text {
key = "txt_Client_Loc" ;
label = "Client's Location" ;
}// text
: edit_box {
key = "edbx_Client_Loc" ;
}// edit_box
} //row
} //boxed_column
: spacer ;
// Job
: boxed_column {
key = "Job_Box" ;
label = "Job" ;
: row { // Row 03 - Name
key = "Row_Job_Name" ;
: text {
key = "txt_Job_Name" ;
label = "Job's Name" ;
}// text
: edit_box {
key = "edbx_Job_Name" ;
}// edit_box
} //row
: row { // Row 04 - Number
key = "Row_Job_Number" ;
: text {
key = "txt_Job_Number" ;
label = "Job's Number" ;
}// text
: edit_box {
key = "edbx_Job_Number" ;
}// edit_box
} //row
} //boxed_column
: spacer ;
// Miscellaneous
: boxed_column {
key = "Miscellaneous_Box" ;
label = "Miscellaneous" ;
: row { // Row 05 - Creator's Initials
key = "Row_Creator_Name" ;
: text {
key = "txt_Creator_Name" ;
label = "Creator's Name" ;
}// text
: edit_box {
key = "edbx_Creator_Name" ;
}// edit_box
} //row
: row { // Row 06 - Date of Creation
key = "Row_Date" ;
: text {
key = "txt_TitleDate" ;
label = "Date" ;
}// text
: edit_box {
key = "edbx_TitleDate" ;
}// edit_box
} //row
: row { // Row 07 - Issued For
key = "Row_Issued_For" ;
: text {
key = "txt_Issued_For" ;
label = "Issued For" ;
}// text
: edit_box {
key = "edbx_Issued_For" ;
}// edit_box
} //row
} //boxed_column
} //boxed_column
: spacer ;
// Revision
: boxed_column {
key = "Column_Revision" ;
label = "Revision" ;
: row { // Row 08 - Quick Choices
key = "Row_Buttons" ;
: button {
key = "btn_IFC" ;
label = "Issued for Construction" ;
}// button
: button {
key = "tbn_AB" ;
label = "As Built" ;
}// button
: radio_column {
key = "RadioCol_WriteMethod" ;
: radio_button {
key = "rbtn_Owt" ;
label = "Clear & Overwrite" ;
}// radio_button
: radio_button {
key = "rbtn_Apnd" ;
label = "Append / New Line" ;
}// radio_button
} //radio_column
} //row
: spacer ;
: row { // Row 09 - Rev Labels
key = "Row_Labels" ;
: text {
key = "txt_Rev" ;
label = "Rev" ;
}// text
: text {
key = "txt_Initials" ;
label = "Initials" ;
}// text
: text {
key = "txt_Description" ;
label = "Description" ;
}// text
: text {
key = "txt_RevDate" ;
label = "Date" ;
}// text
} //row
: row { // Row 10 - Rev Edit Boxes
key = "Row_Rev" ;
: edit_box {
key = "edbx_Rev" ;
}// edit_box
: edit_box {
key = "edbx_Initials" ;
}// edit_box
: edit_box {
key = "edbx_Date" ;
}// edit_box
: edit_box {
key = "edbx_RevDate" ;
}// edit_box
} //row
} //boxed_column
: spacer ;
// Return Commands
: row { // Row 11 - Buttons
key = "Row_Return" ;
: button {
key = "btn_DWGs" ;
action = "(done_dialog 2)" ;
label = "Show Drawings" ;
}// button
: button {
key = "btn_Confirm" ;
action = "(done_dialog 1)" ;
label = "Confirm" ;
}// button
: button {
key = "btn_Cancel" ;
action = "(done_dialog 0)" ;
label = "Cancel" ;
}// button
} //row
ok_cancel ; // How to remove this without throwing errors.
: spacer ;
} // TitleRevUpdate
Every DCL form must contain a control with either the attribute is_default = true
or is_cancel = true
. Each of these attributes can also only be assigned to a single control on the form.
The set of predefined DCL clusters ok_cancel
, ok_only
, ok_cancel_help
, ok_cancel_help_errtile
,ok_cancel_help_info
already contain controls which possess these attributes, thus avoiding the error when you include them in your DCL definition.
As such, to fix your dialog, simply change the DCL to the following:
: row { // Row 11 - Buttons
key = "Row_Return" ;
: button {
key = "btn_DWGs" ;
action = "(done_dialog 2)" ;
label = "Show Drawings" ;
}// button
: button {
key = "btn_Confirm" ;
action = "(done_dialog 1)" ;
label = "Confirm" ;
is_default = true; // <-------------------- Added
}// button
: button {
key = "btn_Cancel" ;
action = "(done_dialog 0)" ;
label = "Cancel" ;
is_cancel = true; // <-------------------- Added
}// button
} //row
The use of is_cancel = true
will also allow the red 'x' in the top-right corner of the dialog to evaluate the action of the control to which is_cancel = true
has been assigned.