明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1578|回复: 4

[基础] [求助] dcl的赋值问题

[复制链接]
发表于 2010-10-15 10:01 | 显示全部楼层 |阅读模式

请教大家一个问题,谢谢大家了:dcl对话框见图所示,我想在前两个edit_box中分别输入1个数,然后点击button计算按钮将他们的和赋给dcl对话框的第3个edit_box(结果要在edit_box中显示出来)。我的l程序代码贴上来,大家帮我看看,谢谢了!!!

 楼主| 发表于 2010-10-15 10:05 | 显示全部楼层
dcl和lisp代码如下(代码是在别人的基础上修改的)
Enter:dialog{
:column{:edit_box { label = "A:"; key = "zjd_x1";value="2";}}
:column{:edit_box { label = "B:"; key = "zjd_x2";value="2";}}
:column{:edit_box { label = "A+B:"; key = "zjd_x3";value="0.0";}}
  :button { label = "计算"; key = "pick";}
ok_cancel;
}


(defun c:test( )
  (setq dcl_id (load_dialog "c:/tmp.dcl"))  
  (setq what_next 2)
  (while (>= what_next 2)
    (new_dialog "Enter" dcl_id)
    (if txt (set_tile "zjd_x3" txt))
    (action_tile "pick" "(done_dialog 2)")
    (setq what_next (start_dialog))
    (if (= what_next 2)
      (progn
        (setq a1 (atof (get_tile "zjd_x1")))
        (setq a2 (atof (get_tile "zjd_x2")))
        (setq a3 (+ a1 a2))
        (setq a3 (rtos a3 2 2))
        (setq txt a3)
      )
    )
  )
  (unload_dialog dcl_id)
  (princ)
)
发表于 2010-10-15 20:12 | 显示全部楼层
游客,本帖隐藏的内容需要发帖数高于 5 才可浏览,你当前发帖数只有 0

 楼主| 发表于 2010-10-15 21:21 | 显示全部楼层
谢谢斑竹了,帮主的代码里面有一个小小的错误改一下就可以了:子函数(a+b)中的key值应该是zjd_x1zjd_x2,还是要感谢帮主!!!改好的代码见下面:
 楼主| 发表于 2010-10-15 21:23 | 显示全部楼层
(defun c:test ()
(if (> (setq dcl_id (load_dialog "c:/tmp.dcl")) 0)
  (progn
  (if (new_dialog "Enter" dcl_id)
    (progn
   (if txt (set_tile "zjd_x3" txt))
   (action_tile "pick" "(a+b)")
   (action_tile "cancel" "(done_dialog 0)")
   (action_tile "accept" "(done_dialog 1)")
   (start_dialog)
  )
   (alert "无法显示对话框!")
  )
  (unload_dialog dcl_id)
)
  (alert "无法加载对话框!")
)
(princ)
)

(defun a+b ()
(set_tile "zjd_x3" (rtos (+ (atof (get_tile "zjd_x1")) (atof (get_tile "zjd_x2"))) 2 3))
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-6-14 17:31 , Processed in 0.193626 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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