irneb Posted June 19, 2011 Posted June 19, 2011 With standard DCL, the answer is: "Yes, you need to rewrite the DCL and close and reopen the dialog." Whether you rewrite it manually for each possibility or programmatically on the fly is up to you. Normal DCL does not have anything like an is_visible property, only an is_enabled. See why I originally suggested it's not a good idea if you have numerous versions of the dialog? A handful is still fine but not 100's. If you're suck with normal DCL, your best bet is to use mode_tile to enable/disable fields per the selection. Quote
Lee Mac Posted June 19, 2011 Posted June 19, 2011 I've looked into the structure and the coding of kruuger's example and I understand the coding but does the program always have to rewrite the dialog coding for each entry in the list when I select it? This is where I'm confused. Which example are you referring to? If the first example, using two dialog definitions, then the dialog must be closed and the second dialog opened. If the second example, (post #17), then no, just use mode_tile statements. Quote
Lee Mac Posted June 19, 2011 Posted June 19, 2011 Here's a simple example using mode_tile statements: ([color=BLUE]defun[/color] c:test ( [color=BLUE]/[/color] *error* _modetiles fo i id tmp ) [color=GREEN];; Example by Lee Mac - www.lee-mac.com[/color] ([color=BLUE]defun[/color] *error* ( msg ) ([color=BLUE]if[/color] ([color=BLUE]<[/color] 0 id) ([color=BLUE]unload_dialog[/color] id)) ([color=BLUE]if[/color] ([color=BLUE]and[/color] tmp ([color=BLUE]setq[/color] tmp ([color=BLUE]findfile[/color] tmp))) ([color=BLUE]vl-file-delete[/color] tmp)) ([color=BLUE]or[/color] ([color=BLUE]wcmatch[/color] ([color=BLUE]strcase[/color] msg) [color=MAROON]"*BREAK,*CANCEL*,*EXIT*"[/color]) ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\n** Error: "[/color] msg [color=MAROON]" **"[/color]))) ([color=BLUE]princ[/color]) ) ([color=BLUE]defun[/color] _modetiles ( value [color=BLUE]/[/color] i ) ([color=BLUE]setq[/color] i -1) ([color=BLUE]foreach[/color] x '([color=MAROON]"b1"[/color] [color=MAROON]"b2"[/color] [color=MAROON]"b3"[/color]) ([color=BLUE]mode_tile[/color] x ([color=BLUE]if[/color] ([color=BLUE]=[/color] value ([color=BLUE]setq[/color] i ([color=BLUE]1+[/color] i))) 0 1)) ) ) ([color=BLUE]cond[/color] ( ([color=BLUE]not[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] fo ([color=BLUE]open[/color] ([color=BLUE]setq[/color] tmp ([color=BLUE]vl-filename-mktemp[/color] [color=BLUE]nil[/color] [color=BLUE]nil[/color] [color=MAROON]".dcl"[/color])) [color=MAROON]"w"[/color])) ([color=BLUE]progn[/color] ([color=BLUE]foreach[/color] x '( [color=MAROON]"button15 : button { width = 20; fixed_width = true; }"[/color] [color=MAROON]"tmp : dialog { label = \"Example\"; spacer;"[/color] [color=MAROON]" : popup_list { key = \"list\"; width = 20; fixed_width = true; } spacer;"[/color] [color=MAROON]" : button15 { label = \"Button 1\"; key = \"b1\"; }"[/color] [color=MAROON]" : button15 { label = \"Button 2\"; key = \"b2\"; }"[/color] [color=MAROON]" : button15 { label = \"Button 3\"; key = \"b3\"; }"[/color] [color=MAROON]" spacer; ok_only;"[/color] [color=MAROON]"}"[/color] ) ([color=BLUE]write-line[/color] x fo) ) ([color=BLUE]setq[/color] fo ([color=BLUE]close[/color] fo)) ([color=BLUE]<[/color] 0 ([color=BLUE]setq[/color] id ([color=BLUE]load_dialog[/color] tmp))) ) ([color=BLUE]new_dialog[/color] [color=MAROON]"tmp"[/color] id) ) ) ([color=BLUE]princ[/color] [color=MAROON]"\n--> Error Loading Dialog."[/color]) ) ([color=BLUE]t[/color] ([color=BLUE]start_list[/color] [color=MAROON]"list"[/color]) ([color=BLUE]foreach[/color] x '([color=MAROON]"Button1"[/color] [color=MAROON]"Button2"[/color] [color=MAROON]"Button3"[/color]) ([color=BLUE]add_list[/color] x)) ([color=BLUE]end_list[/color]) ([color=BLUE]set_tile[/color] [color=MAROON]"list"[/color] [color=MAROON]"0"[/color]) (_modetiles 0) ([color=BLUE]action_tile[/color] [color=MAROON]"list"[/color] [color=MAROON]"(_modetiles (atoi $value))"[/color]) ([color=BLUE]setq[/color] i 0) ([color=BLUE]foreach[/color] x '([color=MAROON]"b1"[/color] [color=MAROON]"b2"[/color] [color=MAROON]"b3"[/color]) ([color=BLUE]action_tile[/color] x ([color=BLUE]strcat[/color] [color=MAROON]"(alert \"You Pressed Button "[/color] ([color=BLUE]itoa[/color] ([color=BLUE]setq[/color] i ([color=BLUE]1+[/color] i))) [color=MAROON]"\")"[/color])) ) ([color=BLUE]start_dialog[/color]) ) ) ([color=BLUE]if[/color] ([color=BLUE]<[/color] 0 id) ([color=BLUE]unload_dialog[/color] id)) ([color=BLUE]if[/color] ([color=BLUE]and[/color] tmp ([color=BLUE]setq[/color] tmp ([color=BLUE]findfile[/color] tmp))) ([color=BLUE]vl-file-delete[/color] tmp)) ([color=BLUE]princ[/color]) ) Quote
irneb Posted June 19, 2011 Posted June 19, 2011 Lee, perhaps another variant could use bitcoded values to turn on/off multiple tiles in one go. Possibly by altering the _modetiles function thus: (defun _modetiles (value / i) (setq i 1) (foreach x '("b1" "b2" "b3") (mode_tile x (if (= (logand i value) i) 1 0)) (setq i (* i 2)) ) ) That way you could (e.g.) turn on b1 and b3 (but not b2) by a call of (_modetiles 5) ... i.e. (_modetiles (+ 1 4)), or (_modetiles (+ (expt 2 0) (expt 2 2))). I think this might be a more "efficient" way for the OP to handle his numerous properties and numerous combinations of properties. Quote
irneb Posted June 19, 2011 Posted June 19, 2011 BTW, the same idea (bitcodes) can be applied to allow for kruuger's original idea of reloading the dialog depending on which attributes to show or not. As an example here's the on-the-fly function to generate the DCL file according to which attributes to load (modeled on your original dialog): (defun load_dialog_test (code / fn f blank attribs) (setq fn (strcat (getvar "TEMPPREFIX") "test.DCL") blank " : column { width=15; :text{label=\" \";}}" attribs '(" : column { width=15; :row { :text{value=\"L=\";width=3;} :edit_box{key=\"L\";}}}" " : column { width=15; :row { :text{value=\"L1=\";width=3;} :edit_box{key=\"L1\";}}}" " : column { width=15; :row { :text{value=\"L2=\";width=3;} :edit_box{key=\"L2\";}}}" " : column { width=15; :row { :text{value=\"B=\";width=3;} :edit_box{key=\"B\";}}}" " : column { width=15; :row { :text{value=\"B1=\";width=3;} :edit_box{key=\"B1\";}}}" " : column { width=15; :row { :text{value=\"B2=\";width=3;} :edit_box{key=\"B2\";}}}" " : column { width=15; :row { :text{value=\"T=\";width=3;} :edit_box{key=\"T\";}}}" " : column { width=15; :row { :text{value=\"s=\";width=3;} :edit_box{key=\"s\";}}}" " : column { width=15; :row { :text{value=\"b=\";width=3;} :edit_box{key=\"b\";}}}" " : column { width=15; :row { :text{value=\"ØD=\";width=3;} :edit_box{key=\"ØD\";}}}" " : column { width=15; :row { :text{value=\"Ød=\";width=3;} :edit_box{key=\"Ød\";}}}" " : column { width=15; :row { :text{value=\"M=\";width=3;} :edit_box{key=\"M\";}}}" ) ) (setq f (open fn "w")) (write-line "testRewrite : dialog {" f) (write-line " label = \"Dialog testing with \\\"visibility\\\"\";" f) (write-line " : column {" f) (write-line " : boxed_row {" f) (write-line " label = \"Werksnorm\";" f) (write-line " : popup_list { key = \"werksnorm\"; }" f) (write-line " }" f) (write-line " : row {" f) (write-line " : boxed_column {" f) (write-line " label = \"Attributen:\";" f) (write-line " : row {" f) (write-line (if (= (logand code 1) 1) (nth 0 attribs) blank ) f ) ;L (write-line (if (= (logand code 2) 2) (nth 1 attribs) blank) f) ;L1 (write-line (if (= (logand code 4) 4) (nth 2 attribs) blank) f) ;L2 (write-line " }" f) (write-line " : row {" f) (write-line (if (= (logand code 8) (nth 3 attribs) blank) f) ;B (write-line (if (= (logand code 16) 16) (nth 4 attribs) blank) f) ;B1 (write-line (if (= (logand code 32) 32) (nth 5 attribs) blank) f) ;B2 (write-line " }" f) (write-line " : row {" f) (write-line (if (= (logand code 64) 64) (nth 6 attribs) blank) f) ;T (write-line (if (= (logand code 128) 128) (nth 7 attribs) blank) f) ;s (write-line (if (= (logand code 256) 256) (nth 8 attribs) blank) f) ;b (write-line " }" f) (write-line " : row {" f) (write-line (if (= (logand code 512) 512) (nth 9 attribs) blank) f) ;ØD (write-line (if (= (logand code 1024) 1024) (nth 10 attribs) blank) f) ;Ød (write-line (if (= (logand code 2048) 2048) (nth 11 attribs) blank) f) ;M (write-line " }" f) (write-line " }" f) (write-line " : boxed_column {" f) (write-line " label = \"Vorschau\";" f) (write-line " : image { width=30; key=\"vorschau\"; }" f) (write-line " }" f) (write-line " }" f) (write-line " ok_only;" f) (write-line " }" f) (write-line "}" f) (close f) (load_dialog fn) ) Then your function using such DCL could be something like this: (defun c:TestDialogReWrite (/ dcl wlst choice) (setq wlst '(("L,L1,B,B2,T,s,ØD,M" . 2923) ;1+2+8+32+64+256+512+2048 ("L1,L2,B,B1,T,b" . 350) ;2+4+8+16+64+256 ("B,B1,T,b" . 344) ;8+16+64+256 ("L1,L2,b" . 262) ;2+4+256 ("L2,B1,T,Ød" . 1108) ;4+16+64+1024 ) choice 0 ) (while (and (>= choice 0) (setq dcl (load_dialog_test (cdr (nth choice wlst)))) (new_dialog "testRewrite" dcl) ) (start_list "werksnorm") (mapcar 'add_list (mapcar 'car wlst)) (end_list) (set_tile "werksnorm" (itoa choice)) (action_tile "werksnorm" "(done_dialog (atoi $value))") (action_tile "accept" "(done_dialog -1)") (setq choice (start_dialog)) (unload_dialog dcl) ) (princ) ) Notice the flicker though, every time the dialog is closed and restarted. Quote
LibertyOne Posted September 1, 2011 Author Posted September 1, 2011 UPDATE: I would have loved to continue on with this, but at the moment I have no use to complete this project due to the fact that I have changed employers. It's been a rough couple of months, but I'm happy to have moved on to something better. As far as this program is in its development, I'll be putting it on ice and working on other things. Perhaps this new job will eventually need in some form a program like this, but hard to tell. Quote
Lee Mac Posted September 1, 2011 Posted September 1, 2011 I hope all goes well for you in your new job LibertyOne, and I look forward to assisting with your next LISP venture Quote
LibertyOne Posted September 1, 2011 Author Posted September 1, 2011 The venture has already started... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.