您可以从lisp代码动态创建DCL文件,加载并启动对话框,然后收集所需输入并关闭对话框并擦除临时DCL文件。
举个例子:
- (defun C:test ( / dcl des dch dcf rtn )
- ;; Example to create DCL on-the-fly and gather input(s)
- ;; Modified version, original by: Lee Mac
- (defun *error* ( msg )
- (and (< 0 dch) (unload_dialog dch))
- (and (eq 'FILE (type des)) (close des))
- (and (eq 'STR (type dcl)) (findfile dcl) (vl-file-delete dcl))
- (and msg (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\nError: " msg)))) (princ)
- ); defun *error*
-
- (and
- (setq dcl (vl-filename-mktemp nil nil ".dcl"))
- (setq des (open dcl "w"))
- (princ
- (strcat
- "test : dialog"
- "{ label = "Get String";"
- " : column"
- " { children_alignment = centered;"
- " : text { value = "Your input: "; }"
- " : edit_box { key = "eb"; edit_width = 26; }"
- " }"
- " spacer_1; ok_cancel;"
- "}"
- ); strcat
- des
- )
- (not (setq des (close des)))
- (< 0 (setq dch (load_dialog dcl)))
- (new_dialog "test" dch)
- (action_tile "eb" "(setq rtn $value)")
- (= 1 (setq dcf (start_dialog)))
- (princ rtn)
- ); and
-
- (*error* nil) (princ)
- ); defun C:test
|