乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 68|回复: 5

[编程交流] [Help] Save and load all tile

[复制链接]

22

主题

326

帖子

185

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
243
发表于 2022-7-6 09:04:57 | 显示全部楼层 |阅读模式
Goodmorning all,
I want to save all tile in a DCL dialog  when 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??
 
Yesterday  i've write
  1. hello:dialog {label="Test";                  : edit_box {                          label = "test";                   key = "kPath";                  [color=red] value = "default" ;[/color]                                     }              }
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

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 09:25:35 | 显示全部楼层
One way is:
 
  1. hello:dialog {label="Test"; : edit_box { label = "test";key = "kPath";[color=blue]value = "" ;[/color]}}
 
.....
(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
and  prompting with a default option by LM
http://lee-mac.com/promptwithdefault.html
回复

使用道具 举报

22

主题

326

帖子

185

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
243
发表于 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

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 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
  1. (setq KeyValueList  (list "Key1" "key2" "key3"))
Set_tile:
  1. (foreach Key KeyValueList      (set_tile key (eval (read key))))
Action_tile:
  1. (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
 
  1. (foreach Key KeyValueList       (set_tile key  (eval  (read (strcat key "_X")))))
 
  1. (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
回复

使用道具 举报

22

主题

326

帖子

185

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
243
发表于 2022-7-6 10:04:30 | 显示全部楼层
Thanks for ur reply, i'll try it ^^
回复

使用道具 举报

4

主题

327

帖子

324

银币

初来乍到

Rank: 1

铜币
19
发表于 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.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-7 08:15 , Processed in 0.636950 second(s), 64 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表