明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 406|回复: 7

[提问] 请教!如何得到list_box选中的多项内容

[复制链接]
发表于 2023-12-31 20:27 | 显示全部楼层 |阅读模式
刚刚开始研究DCL、请教一下各位大神


如何得到list_box选中的多项内容、用get_tile得到的是列表中对应元素的多个序号、

现在不知道如何拆分这些序号、来获取列表中对应的内容了

有没有大神能提供一下具体的获取函数、感谢
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2023-12-31 20:39 | 显示全部楼层
字符串转表或字符串分割 已空格为分隔符  用得到的表去nth  list_box中的数据
 楼主| 发表于 2023-12-31 20:41 | 显示全部楼层
飞雪神光 发表于 2023-12-31 20:39
字符串转表或字符串分割 已空格为分隔符  用得到的表去nth  list_box中的数据

这个原理我能懂、现在就是不知道具体怎么拆分字符串
发表于 2023-12-31 20:42 | 显示全部楼层
  1. (defun str2lst (str del / pos)
  2.         (if (setq pos (vl-string-search del str))
  3.                 (cons (substr str 1 pos) (str2lst (substr str (+ pos 1 (strlen del))) del))
  4.                 (list str)
  5.         )
  6. )
  7. (mapcar '(lambda (x) (nth x '("数据1" "数据2" "数据3" "数据4" "数据5"))) (mapcar 'atoi (str2lst "0 1 2 4" " ")))

评分

参与人数 1明经币 +1 收起 理由
不一样地设计 + 1 很给力!

查看全部评分

 楼主| 发表于 2023-12-31 20:48 | 显示全部楼层

谢谢、这回明白怎么操作了
发表于 2024-1-1 13:03 | 显示全部楼层
  1. (defun mkdcl(str / dclF Fid dcl)
  2.      (write-line(apply'strcat(if(listp str)str(list str)))
  3.        (setq dclF(vl-filename-mktemp nil nil ".dcl")Fid(open dclF "w")))
  4.      (close Fid)
  5.      (setq dcl(load_dialog dclF))
  6.      (vl-file-delete dclF)dcl)
  7. (defun c:tt( / dcl lst l)
  8.   (setq dcl(mkdcl'("ABC:dialog{:list_box{key="1";multiple_select=true;}ok_only;}"))
  9.         lst'("A""B""C""D""E"))
  10.   (new_dialog"ABC"dcl)
  11.   (start_list"1")(vl-every(function add_list)lst)(end_list)
  12.   (action_tile"accept""(setq l(get_tile"1"))(done_dialog 1)")
  13.   (if(=(start_dialog)1)
  14.     (mapcar(function(lambda(x)(nth x lst)))
  15.                   (read(strcat"("l")")))))

(read(strcat"("(get_tile list_box_name)")"))
 楼主| 发表于 2024-1-1 15:15 | 显示全部楼层
llsheng_73 发表于 2024-1-1 13:03
(read(strcat"("(get_tile list_box_name)")"))

谢谢、我现在用的笨方法、直接搜索空格来拆分的
发表于 2024-1-1 17:22 | 显示全部楼层
xiaocainiao 发表于 2024-1-1 15:15
谢谢、我现在用的笨方法、直接搜索空格来拆分的

(read(strcat"("   "0 1 5"  ")"))=>'(0 1 5)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-9 12:27 , Processed in 0.167894 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表