Hi guys,
I just wanted to leave this classical template to load & display & get inputs from dialog.
The reason is because I didn't have enough experience about looking for the actual .dcl file, loading it and displaying it
I was always creating my dialogs on the fly, since Lee Mac has revealed his strategy/method - which is perfect BTW.
Another reason was because I'm always forgetting where the *_tile functions must be located - in this clear sample code the
set/get/mode/action_tileare between the
new_dialog and
start_dialog.
My memory fails and I'm confusing the
load_dialog/new_dialog/start_dialog order, and between which ones I had to use the
tile functions.

; Learning the classical way to load and run dialogs - without creating them on the fly:
(defun C:test
( / *error* dcp dcl dch dcf side len wid radius
)
(and (< 0 dch
) (unload_dialog dch
)) ; Unloads the DCL file associated with dcl_id (obtained from a previous new_dialog call) from memory. Always return nil ); defun *error*
( (not (setq dcp
(findfile "Rectangle.dcl"))) ; trusted path and filename with extension (princ "\nUnable to find the DCL file.") )
(
(setq dcl
(apply '
strcat (cdr (fnsplitl dcp
)))) ; filename with extension, example: "Rectangle.dcl" ; Returns: A positive integer value (dcl_id) if successful, or a negative integer if load_dialog can't open the file.
; The dcl_id is used as a handle in subsequent new_dialog and unload_dialog calls.
); progn
(princ "\nUnable to load the DCL file.") )
( (not (new_dialog "rect" dch
)) ; (new_dialog dlgname dcl_id [action [screen-pt]]) ; Display ; Returns: T, if successful, otherwise nil. (princ "\nUnable to display the dialog") )
(
; Set Default values for the tiles:
(set_tile "CE" "1") ; rectangle justification centered - enable (set_tile "FT" "0") ; fillet toggle - disable ; Set Default values for the lisp symbols - AFTER the default values for the tiles are set:
; Set Default mode for the fillet tile:
(mode_tile "FR" (if (= "1" (get_tile "FT")) 0 1)) ; check the toggle's value and enable/disable accordingly ; Set Default actions for the tiles:
); cond
); vl-prin1-to-string
); action_tile "FT"
(set_tile "error" "Invalid Radius value!") )
(T
(if (= "0" (get_tile "FT")) (setq radius
nil) ) ; set radius to nil if the fillet's toggle is disabled )
); cond
); vl-prin1-to-string
); action_tile "accept"
(/= 1 (setq dcf
(start_dialog))) ; Display the dialog and begin accepting the user inputs ); progn
(princ "\nUser cancelled the dialog.") )
(T ; User finished with dialog, proceed with the inputs
"\nUser has chosen:"
"\nSide: " side
"\nLength: " len
"\nWidth: " wid
"\nRadius: " (if (eq 'STR
(type radius
)) radius
"") ); strcat
); alert
)
); cond
); defun
DCL (Rectangle.dcl) :
rect : dialog
{ label = "Draw a Rectangle";
: boxed_radio_row
{ label = "Select placement method";
: radio_button { key = "LS"; label = "Left Side"; }
: radio_button { key = "CE"; label = "Center"; }
: radio_button { key = "RS"; label = "Right Side"; }
}
: row
{ : boxed_column
{ label = "Size";
: edit_box { key = "X"; label = "Length"; edit_width = 6; }
: edit_box { key = "Y"; label = "Width"; edit_width = 6; }
}
: boxed_column
{ label = "Fillet";
: toggle { key = "FT"; label = "Fillet corners?"; }
: edit_box { key = "FR"; label = "Radius"; }
}
}
spacer; ok_cancel;
: text { label = ""; key = "error"; }
}
I'll continue write from scratch some useless lisp codes that are using dialogs - so hopefully I'll memorize the methodology/technique.
Although one question appeared, how can I stack multiple dialogs? Maybe like this? :
; Will this run and display 3 nested dialogs at once?
And will such thing work? :
; By pressing that button will it display the nested dialog?
)
)
)