>> How do I get rid of the need to hit enter?
@Anonymous-WMA and others reading this...
Setting a user defined variable at the time of tile selection will not seamlessly
work on an edit_box. For this, we have to restructure our thoughts and come up
with a better solution that not only gathers the present state of ALL the tiles
in the dialog, but also allows one to perform tests to ensure the user input is
correct. When the user input is incorrect, issue an alert (which prevents the
dialog from closing):
(action_tile "accept" "(if (XXX_GET) (done_dialog 1))")
Where the following function is placed somewhere ABOVE "new_dialog" and not
buried inside a PROGN, COND, WHILE or any other function other than another DEFUN:
(vl-load-com)
(defun XXX_GET ( / eb1 )
;first get the tile's value and remove any leading and trailing spaces.
;optional is to also remove any undesired leading/trailing characters (such as ', " or .).
;it is assumed that the edit_box has been initiated a value in the "set_tile"
;area (between "new_dialog" and "start_dialog").
(if (setq eb1 (get_tile "Edit_Box_1")) (setq eb1 (vl-string-trim " " eb1)))
;now, enter a COND and perform necessary tests.
;if one of the tests is true, mode_tile the edit box and alert user [in this order].
(cond
;<not eb1> tile was not initiated. this is an unacceptable dialog execution.
(<test eb1 for empty string (STRLEN)> (mode_tile "Edit_Box_1" 2) (alert "Please enter a value."))
(<test eb1 for not a real [or not an integer] (DISTOF)> ...mode_tile and alert)
(<test eb1 for illegal characters if file or folder naming (SNVALID)> ...mode_tile and alert)
(<test eb1 for other characters not allowed (WCMATCH)> ...mode_tile and alert)
(<test eb1 for only lower case letters, etc. (ASCII)> ...mode_tile and alert)
(<test eb1 for minimum or maximum number of characters, etc. (STRLEN)> ...mode_tile and alert)
(<test eb1 for minimum and/or maximum real or integer values (< #1 eb1 #2)> ...mode_tile and alert)
(<test eb1 if layer name does not exist (TBLSEARCH)> ...mode_tile and alert)
(<test eb1 if linetype is not loaded (TBLSEARCH)> ...mode_tile and alert)
(<other tests to eb1 as required> ...mode_tile and alert)
(T (setq MyVariable eb1)) ;all is OK.
);cond
);defun
Alert returns nil - which will not cause the done_dialog to execute where
action_tile accept. The dialog remains open and the incorrect edit box is
highlighted (after the user presses the "OK" button inside the issued alert).
Other Notes:
- (atoi "a") returns 0.
- (atoi "0") returns 0 ...ATOI is not the most desirable test to determine if integer.
- Where possible, employ a list_box, popup_list, or radio_button in lieu of an edit_box.
- Do not "talk to" a radio_button. Instead, assign a key to the radio_column or
radio_row and get_tile the radio_column or radio_row for the value. Set_tile
the radio_column or radio_row will also work in this manner.
The objective of the dialog box is to gather user input. Once the dialog's state
has been recorded, proceed to the "Main Program" of the utility and interpret the
values that have been gathered (GET) from the dialog box.
- By setting user defined variables at the time of tile selection, the ability
to restore the dialog's state after the Cancel button is pressed is lost.
- By recording the dialog's state when the OK button is pressed, restoring the
dialog to the previous state the next time the utility is run can be achieved.
- Action_tile other than "accept" "cancel" and "help" shall only be used to
manipulate the dialog's behavior (start_image, start_list, set_tile, mode_tile,
etc.) or switching to another dialog.
Further down the thread list you posted a revised LSP. Inside there is
no initializing of any of the edit boxes. A simple (set_tile "EditBox1" "")
may be used as a minimum.
Scot-65
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.