TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Biscuits on August 01, 2018, 08:37:45 AM
-
Can anyone suggest how to modify this section of code to use dialogue box rather than the command line?
This DCL stuff is way beyond me. Thanks
(initget 5)
(setq n (getint "\nAdditional Layouts required: "))
(repeat (- n 0)
(command "._layout" "_N" "")
)
-
That code asks the user for an integer, then creates that many layouts.
Where is a dialog needed?
Just to prompt for the integer?
-
You could use a message box: http://www.theswamp.org/index.php?topic=29537.0
I also found this old thread:http://www.theswamp.org/index.php?topic=31107.0 Another MessageBox utility by Keith
-
That code asks the user for an integer, then creates that many layouts.
Where is a dialog needed?
Just to prompt for the integer?
Like this. I can create the DCL file, just don't know how to incorporate into the code.
-
(DEFUN foo (/ accept dh f_help my_path n w@)
(IF (NULL (FINDFILE "foo_dcl.dcl"))
(PROGN (SETQ my_path (STRCAT (SUBSTR (FINDFILE ".\\Icons") 1 (- (STRLEN (FINDFILE ".\\Icons")) 5)) "foo_dcl.dcl")
my_path (OPEN my_path "w")
)
(PRINC (STRCAT "my_foo:dialog{label=\"Add Layouts\";initial_focus=\"n\";"
":edit_box{label=\"How many Layouts do you want do add?\";edit_width=10;key=\"n\";}ok_cancel;}"
)
my_path
)
(CLOSE my_path)
)
)
(DEFUN accept ()
(IF (AND (SETQ n (GET_TILE "n")) (> (ATOI n) 0) (< (ATOI n) 65))
(PROGN (SETQ n (ATOI n)) (DONE_DIALOG 1))
(ACET-UI-MESSAGE "Error:\n\n\n\tNeed an integer between 1 and 64" "Please, correct..." 16)
)
)
(DEFUN f_help ()
(ACET-UI-MESSAGE "How to use:\n\n\n\tWrite your help explanation here..." "My_help title" 32)
)
(IF (> (SETQ dh (LOAD_DIALOG "foo_dcl.dcl")) 0)
(IF (NEW_DIALOG "my_foo" dh)
(PROGN (ACTION_TILE "accept" "(accept)")
(ACTION_TILE "cancel" "(DONE_DIALOG 0)")
(ACTION_TILE "help" "(f_help)")
(SETQ w@ (START_DIALOG))
(UNLOAD_DIALOG dh)
(COND ((= w@ 1) (REPEAT n (COMMAND "_.LAYOUT" "_N" "")))
(T (PRINC "\n-> Nothing to do..."))
)
)
)
(ACET-UI-MESSAGE "Error:\n\n\n\tNo dcl file loaded..." "Message" 16)
)
(PRINC)
)
(DEFUN c:nlayouts () (foo) (PRINC))
;|
(INITGET 5)
(SETQ n (GETINT "\nAdditional Layouts required: "))
(REPEAT (- n 0) (COMMAND "._layout" "_N" ""))
|;
-
oops, use ok_cancel_help instead of ok_cancel
-
Wow, that was more than I expected. Thank you...it works great. Could you tell me how to just hit enter rather than select the OK button? The focus seems to be on the button, but requires it to be selected.
-
Somewhat more generic - you want to be working with the "action" of the tile. If you have a single-purpose DCL you can state it in the DCL file e.g.
action = "(setq count_var (atoi $value))";
Not necessary to use global variables for this, as long as you know what the variable name is. The "$value" is the current value of the tile, which is always a string - you need to convert (and possibly test) it if you need to work on it as another data type.
If the dialog is more general purpose, or if you want more control over the action from your code, you can call the (action_tile ...) function. This will do the same thing as above. Mind the quoted strings, using escapes ( \ ) where needed.
-
Thanks for the help...works great. Couldn't get the focus to change, but I can live with that. Thanks again!