Qonfire Posted January 18, 2012 Posted January 18, 2012 (edited) Hello I've trouble with hiding and restoring dialog. It seems like, hiding dialog should be a loop task.I wish somebody answers on the following question. 1. to hide a dialog, it should be (done_dialog 4) lets say,to retrieve it, (start_dialog). Q: Start _dialog loads blank dialog.Do I have a choice not to load it from blank.,meaning keep the user selections before hiding. 2. If dialog starts blank, than code should be able in such a way that will reinsert the data user selected.Q:Is it right? Thanks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq flag 4) (setq dcl_id (load_dialog "test_dist.dcl")) (while (> flag 2) (if (not (new_dialog "test1" dcl_id)) (exit) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq Ldist ( getdist "\nGet Distance B.W : ")) (setq Sdist ( getdist "\nGet Distance B.L: ")) (setq lhz '("Light Hazard" "Ordinary Hazard" "Extra Hazard >=0.25" "Extra Hazard <=0.25" )) (start_list "selections1") (mapcar 'add_list lhz) (end_list) (action_tile "selections1" (strcat "(setq item (atoi (get_tile \"selections1\"))) (cond ( (= item 3) (setq maxd 15) (setq maxa 130) (set_tile \"edbox1\" \"15\")(set_tile \"edbox2\" \"130\")) ( (= item 2) (setq maxd 12) (setq maxa 100) (set_tile \"edbox1\" \"12\")(set_tile \"edbox2\" \"100\")) ( (= item 1) (setq maxd 15) (setq maxa 130) (set_tile \"edbox1\" \"15\")(set_tile \"edbox2\" \"130\")) ( (= item 0) (setq maxd 15) (setq maxa 225) (set_tile \"edbox1\" \"15\")(set_tile \"edbox2\" \"225\")) ))")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (action_tile "opt1" "(done_dialog 4)") (setq flag (start_dialog)) (if (= flag 4)(getdist "\npick a point")) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (unload_dialog dcl_id) Edited January 20, 2012 by Qonfire Quote
Qonfire Posted January 20, 2012 Author Posted January 20, 2012 Good morning,evening,afternoon My hoper for answer are still there. How to hide dialog and than restore it with selections on dialog prior to hide it. Quote
Qonfire Posted January 24, 2012 Author Posted January 24, 2012 Hello I start loosing hope on this one. Will my question be answered.I hope its not personal. thanks Quote
Qonfire Posted January 24, 2012 Author Posted January 24, 2012 Thanks for encouragement super member Quote
Lee Mac Posted January 24, 2012 Posted January 24, 2012 An example to consider: ([color=BLUE]defun[/color] c:example ( [color=BLUE]/[/color] *error* dcf dch dcl p tmp x y ) [color=GREEN];;------------------------------------------------------------;;[/color] [color=GREEN];; DCL Example demonstrating how to temporarily dismiss a ;;[/color] [color=GREEN];; dialog to allow operations to occur within the drawing ;;[/color] [color=GREEN];; area. ;;[/color] [color=GREEN];; ;;[/color] [color=GREEN];; Author: Lee Mac, Copyright © 2012 - www.lee-mac.com ;;[/color] [color=GREEN];;------------------------------------------------------------;;[/color] ([color=BLUE]defun[/color] *error* ( msg ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] dch ([color=BLUE]<[/color] 0 dch)) ([color=BLUE]setq[/color] dch ([color=BLUE]unload_dialog[/color] dch)) ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] tmp ([color=BLUE]findfile[/color] tmp)) ([color=BLUE]vl-file-delete[/color] tmp) ) ([color=BLUE]if[/color] ([color=BLUE]not[/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]"\nError: "[/color] msg)) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]cond[/color] ( ([color=BLUE]not[/color] ([color=BLUE]and[/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=BLUE]setq[/color] dcl ([color=BLUE]open[/color] tmp [color=MAROON]"w"[/color])) ([color=BLUE]foreach[/color] line '( [color=MAROON]"example : dialog { label = \"Example\"; spacer;"[/color] [color=MAROON]" : row {"[/color] [color=MAROON]" : column {"[/color] [color=MAROON]" : edit_box { key = \"x\"; label = \"X:\"; }"[/color] [color=MAROON]" : edit_box { key = \"y\"; label = \"Y:\"; }"[/color] [color=MAROON]" }"[/color] [color=MAROON]" : button { key = \"p\"; label = \">>\"; fixed_height = false; }"[/color] [color=MAROON]" }"[/color] [color=MAROON]" spacer_1; ok_cancel;"[/color] [color=MAROON]"}"[/color] ) ([color=BLUE]write-line[/color] line dcl) ) ([color=BLUE]<[/color] 0 ([color=BLUE]setq[/color] dcl ([color=BLUE]close[/color] dcl) dch ([color=BLUE]load_dialog[/color] tmp))) ) ) ([color=BLUE]princ[/color] [color=MAROON]"\nError Creating DCL."[/color]) ) ( [color=BLUE]t[/color] ([color=BLUE]while[/color] ([color=BLUE]not[/color] ([color=BLUE]member[/color] dcf '(0 1))) ([color=BLUE]cond[/color] ( ([color=BLUE]not[/color] ([color=BLUE]new_dialog[/color] [color=MAROON]"example"[/color] dch)) ([color=BLUE]princ[/color] [color=MAROON]"\nError Loading DCL."[/color]) ([color=BLUE]setq[/color] dcf 0) ) ( [color=BLUE]t[/color] ([color=BLUE]if[/color] x ([color=BLUE]set_tile[/color] [color=MAROON]"x"[/color] x)) ([color=BLUE]if[/color] y ([color=BLUE]set_tile[/color] [color=MAROON]"y"[/color] y)) ([color=BLUE]action_tile[/color] [color=MAROON]"x"[/color] [color=MAROON]"(setq x $value)"[/color]) ([color=BLUE]action_tile[/color] [color=MAROON]"y"[/color] [color=MAROON]"(setq y $value)"[/color]) ([color=BLUE]action_tile[/color] [color=MAROON]"p"[/color] [color=MAROON]"(done_dialog 2)"[/color]) ([color=BLUE]action_tile[/color] [color=MAROON]"accept"[/color] ([color=BLUE]vl-prin1-to-string[/color] '([color=BLUE]cond[/color] ( ([color=BLUE]or[/color] ([color=BLUE]null[/color] x) ([color=BLUE]null[/color] ([color=BLUE]distof[/color] x))) ([color=BLUE]alert[/color] [color=MAROON]"\nX Value not valid."[/color]) ) ( ([color=BLUE]or[/color] ([color=BLUE]null[/color] y) ([color=BLUE]null[/color] ([color=BLUE]distof[/color] y))) ([color=BLUE]alert[/color] [color=MAROON]"\nY Value not valid."[/color]) ) ( ([color=BLUE]done_dialog[/color] 1) ) ) ) ) ([color=BLUE]setq[/color] dcf ([color=BLUE]start_dialog[/color])) ) ) ([color=BLUE]if[/color] ([color=BLUE]=[/color] 2 dcf) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] p ([color=BLUE]getpoint[/color] [color=MAROON]"\nPick Point: "[/color])) ([color=BLUE]setq[/color] x ([color=BLUE]rtos[/color] ([color=BLUE]car[/color] p) 2 4) y ([color=BLUE]rtos[/color] ([color=BLUE]cadr[/color] p) 2 4) ) ) ) ) ([color=BLUE]if[/color] ([color=BLUE]=[/color] 1 dcf) ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"POINT"[/color]) ([color=BLUE]list[/color] 10 ([color=BLUE]distof[/color] x) ([color=BLUE]distof[/color] y) 0.0))) ) ) ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] dch ([color=BLUE]<[/color] 0 dch)) ([color=BLUE]setq[/color] dch ([color=BLUE]unload_dialog[/color] dch)) ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] tmp ([color=BLUE]findfile[/color] tmp)) ([color=BLUE]vl-file-delete[/color] tmp) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Quote
Qonfire Posted January 24, 2012 Author Posted January 24, 2012 Thanks LEE you just made my day. Quote
Lee Mac Posted January 24, 2012 Posted January 24, 2012 You're welcome, I hope you can learn from the code. Quote
Qonfire Posted January 26, 2012 Author Posted January 26, 2012 (edited) Hello dear teachers I'm trying to learn from the code posted above, by breaking it into parts. (setq tmp (vl-filename-mktemp nil nil ".dcl")) (setq dcl (open tmp "w")) (foreach line '( "test1 : dialog {" " : row { : text {label= \"Select Hazard Group\" ; alignment = centered ; } " " : spacer { width = 5 ; } " " : edit_box {key = \"edbox1\" ; label = \"Max Spacing\"; width = 1 ; alignment = right ; } " " : spacer { width = 1 ; }" " : edit_box { key = \"edbox2\" ; label = \"Max.Area\" ; width = 2 ; alignment = right ; } " " : spacer { width = 2 ; } " " : edit_box { key = \"edbox3\" ; label = \"#Sprk\" ; width = 2 ; alignment = right; } " " }" " : popup_list { alignment = bottom ; key = \"selections1\" ; width = 10 ; alignment = centered ; } " " : row { : button { label = \"Get Bay W\" ; key = \"opt2\" ; }" " : button { label = \"Get Bay L\"; key = \"opt2\" ; }" " : edit_box { key = \"edbox4\" ; label = \"Value:\"; edit_width = 5 ; value = 1 ; alignment = left ; }" " : edit_box { key = \"edbox5\" ; label = \"Value:\" ; edit_width = 5 ; value = 1 ; alignment = left ; }" " } " " : edit_box { key = \"myval2\" ; value = 1 ; alignment = left ; height = 5 ; width = 5; } " " : row { : button { label = \"Calc\" ; key = \"opt1\" ; width = 1; } " " : spacer { width = 50 ; }" " ok_only ; " " }} " ) (write-line line dcl) ) (< 0 (setq dcl (close dcl) [color="red"] ;;;;are we closing dialog here? whats a final value on this line[/color] dch (load_dialog tmp) [color="red"] ;;;; whats a value on this line, I have 32 and the value goes by one each time 32 times dialog was loaded?[/color] ) ) (start_dialog) ;i added this 2 lines here for now it works, in this case what are the values for (start_dialog) (done_dialog ) (done_dialog ) thank you Edited January 26, 2012 by Qonfire Quote
BlackBox Posted January 26, 2012 Posted January 26, 2012 An example to consider: <snip> ([color=BLUE]setq[/color] tmp ([color=BLUE]vl-filename-mktemp[/color] [color=BLUE]nil[/color] [color=BLUE]nil[/color] [color=MAROON]".dcl"[/color])) <snip> Interesting... So rather than have a permanent DCL file saved somewhere, you actually recreate a temporary DCL file each time the command is invoked? Very interesting, indeed. Quote
Lee Mac Posted January 26, 2012 Posted January 26, 2012 Interesting... So rather than have a permanent DCL file saved somewhere, you actually recreate a temporary DCL file each time the command is invoked? Yes, I only use this method for small dialogs with only a few lines to the DCL file - it is convenient (I don't need to remind users to save the extra file to the support path) and unobtrusive (the file is cleaned up after the program has finished, leaving no traces of the command behind); of course, for larger applications (say, this), where the DCL file is perhaps a few hundred lines long, I don't create a temporary file, but rather check for the file in a specific location. Quote
BlackBox Posted January 26, 2012 Posted January 26, 2012 Very informative, Lee... Educational even, as always. Cheers, mate! Quote
Qonfire Posted January 26, 2012 Author Posted January 26, 2012 I don't get something, whatever I do ----- done_dialog returns (0 0) ex. start_dialog 0. (cant save done _dialog 4) to have returned value 4 Neep help. Quote
Lee Mac Posted January 26, 2012 Posted January 26, 2012 I don't get something, whatever I do ----- done_dialog returns (0 0) ex. start_dialog 0. (cant save done _dialog 4) to have returned value 4Neep help. Read the help docs. done_dialog Return Values A two-dimensional point list that is the (X,Y) location of the dialog box when the user exited it. start_dialog Return Values The start_dialog function returns the optional status passed to done_dialog. Quote
Qonfire Posted January 26, 2012 Author Posted January 26, 2012 (edited) start_dialog Return Values The start_dialog function returns the optional status passed to done_dialog. IF (done _dialog 4) start dialog is 4? I read help I still didn't get it. A little bit of elaboration will be greatly appreciated. Thank you Edited January 26, 2012 by Qonfire Quote
Lee Mac Posted January 26, 2012 Posted January 26, 2012 The start_dialog function will return the value of the status argument passed to the done_dialog function. Quote
Qonfire Posted January 26, 2012 Author Posted January 26, 2012 If done _dialog has an argument 4 (done_dialog 4) it means that start _dialog has a value 4? correct? Quote
Lee Mac Posted January 26, 2012 Posted January 26, 2012 If done _dialog has an argument 4 (done_dialog 4) it means that start _dialog has a value 4? correct? (start_dialog) will return a value of 4, yes. 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.