土木在线论坛 \ 建筑设计 \ CAD下载及教程 \ 通用函数 数据输入窗体

通用函数 数据输入窗体

发布于:2009-09-07 09:32:07 来自:建筑设计/CAD下载及教程 [复制转发]
[code];;;=================================================================*
;;; 定义通用数据输入窗体 *
;;; *
;;;=================================================================*
;|;注意,调用参数均为字符串形式 *
;;;返回:字符串列表 *
;;;-----------------------------------------------------------------*
;;;示例: *
(ZL-INPUTBOX *
"显示的对话框名称" *
'(("editbox" *
"editbox显示的说明" *
"editbox显示值" *
"20" *
) *
("popup_list" *
"popup_list显示的说明" *
("列表值1" "列表值2" "...") *
"20" *
) *
) *
) *
;;;=================================================================*
;;|;
(vl-load-com)
;;;=================================================================*
(defun ZL-INPUTBOX (STR_DIANAME LST /
LIST->DCL TEMPFILENAME F1
STR_JG I N DCLID
LST_RESULT
)
;;==================================================================*
;;功能:根据控件信息表,生成DCL语言的文本 *
;; 注意,调用参数均为字符串形式 *
;;示例:(list->dcl '( "editbox" "editbox显示的说明" "editbox显示值" "20") 100)
;; (list->dcl '( "popup_list" "popup_list显示的说明" ("列表值1" "列表值2" "...")"20") 101)
;; (list->dcl '( "popup_list" "popup_list显示的说明" "列表值1\\n列表值2\\n..." "20") 102)
;;返回:与控件对应的dcl文本
(defun LIST->DCL (LST KEY_I / X)
(cond
;;
((wcmatch (car LST) "ZML84*")
(strcat
":button{"
(strcat "\nlabel=\""
(nth 0 LST)
"\";"
"\nis_enabled = false;"
)
"\n}\n"
)
)
;;
((= (car LST) "editbox")
(strcat
":edit_box{"
"\nallow_accept = true ;"
(strcat "\nedit_width ="
(nth 3 LST)
";"
)
"\nfixed_width = true ;"
(strcat "\nkey =\"" (itoa KEY_I) "\";")
(strcat "\nlabel=\""
(nth 1 LST)
"\";"
)
(strcat "\nvalue=\""
(nth 2 LST)
"\";"
)
"\n}\n"
)
)
;;
((= (car LST) "popup_list")
(strcat
":popup_list{"
(strcat "\nwidth ="
(nth 3 LST)
";"
)
(strcat "\nlabel=\""
(nth 1 LST)
"\";"
)
(strcat "\nkey =\"" (itoa KEY_I) "\";")
(cond
((= (type (nth 2 LST)) 'STR)
(strcat "\nlist=\""
(nth 2 LST)
"\";"
)
)
((= (type (nth 2 LST)) 'list)
(strcat
"\nlist=\""
(apply
'strcat
(mapcar
'(lambda (X)
(strcat "\\n"
(vl-princ-to-string X)
)
)
(nth 2 LST)
)
)
"\";"
)
)
) ;_结束 cond
"\n}\n"
)
)
;;
((= (car LST) "text")
(strcat
":text{"
(strcat "\nlabel=\""
(nth 1 LST)
"\";"
)
"\n}\n"
)
)
;;
((= (car LST) "spacer_1")
(strcat "\n"
(nth 0 LST)
";\n"
)
)
;;; ((/= (LIST->DCL (cons "editbox" LST) KEY_I) "")
;;; (LIST->DCL (cons "editbox" LST) KEY_I)
;;; )
(t "")
) ;_结束 cond
) ;_结束defun
;;==================================================================*
;;功能:定义按下确定按钮后的操作
(defun GETINPUT (LEN / I N TMP)
(setq RESULTLIST '()
I 0
)
(repeat (length LST)
(setq N (nth I LST))
(cond
;;
((= (car N) "editbox")
(setq LST_RESULT
(cons (get_tile (itoa I)) LST_RESULT)
)
)
;;
((= (car N) "popup_list")
(setq TMP (nth 2 N))
;;tmp有两种格式:字符形式的 和 表形式
;;如果是字符格式的,就转换为表(以\n分割)
(cond
((= (type (nth 2 N)) 'STR)
(setq TMP "*INPUTBOX函数 有待完善*")
)
((= (type (nth 2 N)) 'list)
(setq TMP (nth (atoi (get_tile (itoa I))) TMP))
)
)
(setq LST_RESULT
(cons TMP LST_RESULT)
)
)
;;

;;
(t
(setq LST_RESULT
(cons NIL LST_RESULT)
)
)
)
(setq I (1+ I))
)
(setq LST_RESULT (reverse LST_RESULT))
) ;_结束defun
;;==================================================================*
(setq TEMPFILENAME (vl-filename-mktemp "dcltmp.dcl"))
(setq F1 (open TEMPFILENAME "w"))

;;组织头部
(setq STR_JG (strcat
"InputBox:dialog {"
(strcat "\nlabel =\"" STR_DIANAME "\";")
)
)
;;组织正文
(setq I 0)
(repeat (length LST)
(setq N (nth I LST))
(setq STR_JG (strcat STR_JG
(LIST->DCL N I)
)
)
(setq I (1+ I))
)

;;组织按钮
(setq STR_JG
(strcat STR_JG
"\nspacer_0;"
"\nok_cancel;\n}\n"
)
)
;;写入文件
(princ STR_JG F1)
;;关闭文件
(close F1)
(setq DCLID (load_dialog TEMPFILENAME))
(if (not (new_dialog "InputBox" DCLID ""))
(progn (alert "对话框加载失败!") (exit))
)
(action_tile
"accept"
"(GetInput Lst ) (done_dialog 1)"
)
(start_dialog)
(unload_dialog DCLID)
(vl-file-delete TEMPFILENAME)
;;返回
LST_RESULT
)
;;;========================================================*
;;;测试

;|(defun C:TT ()
(ZL-INPUTBOX
"身份验证"
'(("editbox" "用户名:" "USER" "20")
("editbox" "口 令:" "" "20")
("popup_list"
"类 型:"
("受限用户" "一般用户" "超级管理员")
"20"
)
;;; ("spacer_1")
( "ZML84作品,必属精品。")
;;; ("spacer_1")
)
)
)
;|[/code] 未命名2.jpg

[ 本帖最后由 zml1984 于 2009-9-7 09:36 编辑 ]

全部回复(8 )

只看楼主 我来说两句
  • czb203
    czb203 沙发
    感觉很不错的谢谢楼主啊
    2011-11-18 20:16:18

    回复 举报
    赞同0
  • stillwatersrmh
    啥意思这是 这是干嘛用的?
    2010-12-08 20:43:08

    回复 举报
    赞同0
加载更多
这个家伙什么也没有留下。。。

CAD下载及教程

返回版块

52.08 万条内容 · 657 人订阅

猜你喜欢

阅读下一篇

图层工具 之 选择指定对象所在图层的所有对象

;;;=================================================*;;; 有关图层的实用工具 *;;; *;;; *;;;=================================================*;;; 功能:选择指定对象所在图层的所有对象 *;;; 参数:无 *;;; 返回:执行本程序后,所在图层所有对象呈被选择状态*

回帖成功

经验值 +10