通用函数 数据输入窗体
zml1984
zml1984 Lv.3
2009年09月07日 09:32:40
只看楼主

[code];;;=================================================================*;;; 定义通用数据输入窗体 *;;; *;;;=================================================================*;|;注意,调用参数均为字符串形式 *;;;返回:字符串列表 *

[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 编辑 ]
tzgsky-2008
2009年11月25日 07:29:44
2楼
最近正要学习一下这个,下来研究一下,万分感谢
回复
施工cad
2010年03月21日 11:06:11
3楼
已下载,慢慢留着学习:call:
回复
hello88888
2010年10月02日 20:41:29
4楼
路过,不下,积分,谢谢,为人民服务
回复
lin_461045462
2010年11月30日 19:04:39
5楼
谢谢楼主的分享
收下啦,慢慢看,学习学习
谢谢
回复
x0x0x0x045
2010年11月30日 19:09:33
6楼
看不明白啊,不知道啥意思。
回复
panba
2010年12月03日 09:24:58
7楼
ZML84作品,必属精品。:handshake
精品公开,敬佩敬佩。学习了。
回复
stillwatersrmh
2010年12月08日 20:43:42
8楼
啥意思这是 这是干嘛用的?
回复
czb203
2011年11月18日 20:16:18
9楼
感觉很不错的谢谢楼主啊
回复

相关推荐

APP内打开