ketxu 发表于 2022-7-6 09:04:57

[Help] Save and load all tile

Goodmorning all,
I want to save all tile in a DCL dialogwhen it unload (store in a list), and when it reload, Dialog can restore all value of controls from last value, how can i do it??
 
Yesterdayi've write

hello:dialog {label="Test";                  : edit_box {                        label = "test";                   key = "kPath";                   value = "default" ;                                     }            }
When the first dialog load, it will show "default"
Now i goto change it to "new"
And i need in the next time load, it show "new", not "default" any more
 
I find a link below, but i don't know what/ and how i can use
http://www.cadtutor.net/forum/showthread.php?54791-DCL-Image-slide-by-list-box-amp-edit-box-help!&
 
 
Thanks all

pBe 发表于 2022-7-6 09:25:35

One way is:
 

hello:dialog {label="Test"; : edit_box { label = "test";key = "kPath";value = "" ;}}
 
.....
(set_tile "kPath" (if (not def) "Default" def))
.....
(action_tile "kPath" "(setq def $value)")
.....
 
You may want to look at localising variable by LM
http://lee-mac.com/localising.html
andprompting with a default option by LM
http://lee-mac.com/promptwithdefault.html

ketxu 发表于 2022-7-6 09:40:10

Thank you,OK, i understand assign value to one control now, but i want do it with all of control in dialog (have many other control ) or i have to do with each of them ?
I started learn DCL yesterday, so ....

pBe 发表于 2022-7-6 09:51:45

 
for multiple action_tile/set_tile it would be easier to name your variable the same as the key name.
which means gloabal variables

(setq KeyValueList(list "Key1" "key2" "key3"))
Set_tile:

(foreach Key KeyValueList      (set_tile key (eval (read key))))
Action_tile:

(foreach Key KeyValueList      (action_tile Key             (vl-prin1-to-string (quote(setq key $key)))             )
or you could add an additional character at the end of the keyname
 

(foreach Key KeyValueList       (set_tile key(eval(read (strcat key "_X")))))
 

(foreach Key KeyValueList      (action_tile Key             (vl-prin1-to-string (quote(set (setq tmp (read (strcat          $key "_X"))) $key)))             )         )
 
Which gives you variable "key1_x" for key "Key1"
Hope this helps

ketxu 发表于 2022-7-6 10:04:30

Thanks for ur reply, i'll try it ^^

JohnM 发表于 2022-7-6 10:14:01

You might want to write the dialog input to a file then retrieve it when the dialog opens.
This will give you more options later as you write bigger more complicated projects.
Once you get comfortable with it you can have programs that allows the user to save different settings and then load those settings.
页: [1]
查看完整版本: [Help] Save and load all tile