Thanks Roy,
I've followed the steps:
1. - Solved
2.a. - Could not figure out how to obtain the key from " ok_cancel; " in the dcl file, so created them "manually" instead, using : button
2.b. - Solved with alert, but could not figure out the error tile, since included the new loop in the .lsp file which resets the dialog, hence the message left unseen
3. - Will be solved, thanks I'll work about it thru lisp
Heres the progress:
DCL
// Input_Test.dcl
Input_Test
: dialog
{ label = "Test dialog";
: edit_box
{
key = "K1";
label = "Fill String";
edit_width = 20;
edit_limit = 12;
is_enabled = true;
}
: edit_box
{
key = "K2";
label = "Fill Real";
edit_width = 20;
edit_limit = 12;
is_enabled = true;
}
: edit_box
{
key = "K3";
label = "Fill Integer";
edit_width = 20;
edit_limit = 12;
is_enabled = true;
}
spacer;
// ok_cancel;
: row
{
alignment = bottom;
: button // add done, and exit keys instead of ok_cancel buttons
{
key = "done";
label = "OK";
is_default = true;
width = 3;
fixed_height = true;
alignment = left;
}
: button
{
key = "exit";
label = "CANCEL";
is_default = false;
width = 3;
fixed_height = true;
alignment = right;
}
}
: errtile
{
width = 34;
}
}
LSP
; Input_Test.lsp
(vl-load-com)
(defun C:test ( / Lst )
(setq Lst (list (list))) ; create nested list '(nil) - so it would be non-nil value
(while
(and
Lst ; if Cancel is pressed this loop will stop
(or (/= (length Lst) 3) ; all edit_box were filled
(member "" (mapcar 'cdr Lst))) ; all edit_box contain valid strings
)
(setq Lst (GetInput)) ; must use subfunction, so it will work inside this loop
)
(alert (vl-princ-to-string Lst)) ; alert the end list result
(princ)
); defun
(defun GetInput ( / dcl_id dlgRtn RtnLst )
(if (findfile "Input_Test.dcl")
(progn
(setq dcl_id (load_dialog "Input_Test.dcl"))
(if (not (new_dialog "Input_Test" dcl_id)) (exit) )
(foreach x '("K1" "K2" "K3")
(action_tile x (strcat "(setq RtnLst (cons (cons $key $value) RtnLst))")) ; $key will work also
)
(action_tile "done"
"(if
(vl-some
(quote
(lambda (x)
(= (get_tile x) \"\")
)
)
(list \"K1\" \"K2\" \"K3\")
)
(alert \"You must fill everything!\")
(done_dialog)
)"
)
(action_tile "exit" "(setq RtnLst nil) (done_dialog)")
(setq dlgRtn (start_dialog)) ; If Cancel is pressed dlgRtn will be 0.
(unload_dialog dcl_id)
)
(alert "Could not find the \nInput_Test.dcl file!")
)
; (if (/= 0 dlgRtn) ; unneeded, since the "manual" OK CANCEL buttons
(reverse RtnLst)
; )
)
Hi Marko, I've just seen your comment... will reply soon about it, thanks in advance.
EDIT:
Marko,
The functions checking for string, real, int input seems to work. I tried writing something similar, before Roy's comment (also by using vl-every with vl-string->list).
I'll check yours more carefully and try to improve them, one thing I noticed that "" gets valid integer input.
BTW 1234567890 can be strings aswell, so perhaps checking if the string is /= "" may be enough ( for example "Grrr1337" won't be treated as a valid string ).
I like your method of loading the dcl, using read-line - its new for me!
Thanks alot!
This wiring of dcl-lsp with *_tile functions is kinda annoynig I hope I'll get use to it.