标准化输入对话框lisp代码
guangdonglbq
2008年04月19日 09:07:21
只看楼主

;;;标准输入对话框;;;调用形式 (InputBox 显示的对话框名称 表( ( "editbox显示的说明" "editbox显示值" "editbox显示宽度") ...) );;;注意,调用参数均为字符串形式;;;返回值为与输入表长度相等的字符串列表;;;注意:以下代码未对输入代码格式进行检查,有需要时,需人加入格式检查的代码(defun InputBox (strDialogName EditBoxDefList

;;;标准输入对话框
;;;调用形式 (InputBox 显示的对话框名称 表( ( "editbox显示的说明" "editbox显示值" "editbox显示宽度") ...) )
;;;注意,调用参数均为字符串形式
;;;返回值为与输入表长度相等的字符串列表
;;;注意:以下代码未对输入代码格式进行检查,有需要时,需人加入格式检查的代码
(defun InputBox (strDialogName EditBoxDefList
/ ResultList fStream dclname tempFileName fileN fileStream templist i
dclid)
;;;-------------------------------------------------
(defun GetInput (len)
(setq i 1
ResultList nil
)

(repeat len
(setq ResultList
(append ResultList (list (get_tile (itoa i))))
)

(setq i (1+ i))
)
)
;;;-------------------------------------------------
(setq tempFileName (vl-filename-mktemp "dcltmp.dcl"))
(setq fileN (open tempFileName "w"))

(setq fileStream (list
"InputBox:dialog {\n"
(strcat "label =\"" strDialogName "\";\n")
)
)
(setq i 0)
(repeat (length EditBoxDefList)
(setq templist (nth i EditBoxDefList))
(setq fileStream (append fileStream
(list
":edit_box{\n"
"allow_accept = true ;\n"
(strcat "edit_width =" (caddr templist) ";\n")
"fixed_width = true ;\n"
(strcat "key =\"" (itoa (1+ i)) "\";\n")
(strcat "label=\"" (car templist) "\";\n")
(strcat "value=\"" (cadr templist) "\";\n")
)
)
)

(setq i (1+ i))
)

(setq fileStream (append fileStream
(list

"} ok_cancel;\n"
"}\n"
)
)
)
(foreach fStream
fileStream
(princ fStream fileN)
)
(close fileN)

(setq dclname tempFileName)


(setq dclid (load_dialog dclname))
(if (not (new_dialog "InputBox" dclid ""))
(progn (alert "对话框加载失败!") (exit))
)

(action_tile "accept" "(GetInput (length EditBoxDefList) ) (done_dialog 1)" )

(start_dialog)

(unload_dialog dclid)
(vl-file-delete dclname)

ResultList
)
;;;-------------------------------------------------
免费打赏

相关推荐

APP内打开