明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1549|回复: 2

DCL的输入值的检测

[复制链接]
发表于 2005-4-10 12:59:00 | 显示全部楼层 |阅读模式
在LISP中,如果检测到DCL对话框中输入的数值有误,将弹出ALERT,然后如何记录已经输入的数据,并空白EDIT?


我以前是重新从头再开始运行程序,很不理想,谁有这方面的LISP SAMPLE?
发表于 2005-4-10 13:25:00 | 显示全部楼层
参考一下这个程序: ;AUTOLISP CODING STARTS HERE
(prompt "\nType TEST_DCL3 to run.....") (defun C:TEST_DCL3 (/ dcl_id fn fname) (vl-load-com) (create_dialog) (setq dcl_id (load_dialog fname))
(if (not (new_dialog "temp" dcl_id))
(exit)
) ;if (set_tile "name" "Enter Name Here")
(mode_tile "name" 2)
(action_tile "name" "(setq name $value)")
(action_tile "age" "(setq age $value)")
(action_tile "accept" "(val1)") (start_dialog)
(unload_dialog dcl_id) (alert (strcat "Your name is " name
"\nand you are " age
" years of age."
)
) (vl-file-delete fname) (princ) ) ;defun ----------------------- (defun val1 () (if (= (get_tile "name") "Enter Name Here")
(progn
(set_tile "error" "You must enter a name!")
(mode_tile "name" 2)
) ;progn
(val2)
) ;if ) ;defun ------------------- (defun val2 () (if (< (atoi (get_tile "age")) 1)
(progn
(set_tile "error" "Invalid Age - Please Try Again!!")
(mode_tile "age" 2)
) ;progn
(done_dialog)
) ;if ) ;defun ------------------- (defun create_dialog () (setq fname (vl-filename-mktemp "dcl.dcl")) (setq fn (open fname "w")) (write-line
"temp : dialog { label = \"Test Dialog No 3\";
: edit_box { label = \"Enter Your Name :\"; mnemonic = \"N\";
key = \"name\"; alignment = centered; edit_limit = 30;
edit_width = 30; } : edit_box { label = \"Enter Your Age :\";
mnemonic = \"A\"; key =\"age\"; alignment = centered;
edit_limit = 3; edit_width = 3; value = \"22\";
} : button { key = \"accept\"; label = \"OK\";
is_default = true; fixed_width = true; alignment = centered;
} : errtile { width = 34; } }"
fn
) (close fn) ) ;defun (princ)
;AUTOLISP CODING ENDS HERE
 楼主| 发表于 2005-4-11 12:39:00 | 显示全部楼层
谢谢ljpnb,它是用errtile来解决的.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-17 09:50 , Processed in 0.158640 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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