它们基本上导致相同的对话行为;但请注意,这两个表达式都不是必需的,因为accept和cancel互动程序的操作语句是预定义的,done\u对话框返回值分别为1和0。
考虑以下快速示例来验证这一点:
- (defun c:dcltest ( / *error* dch dcl des )
- (defun *error* ( msg )
- (if (< 0 dch) (unload_dialog dch))
- (if (= 'file (type des)) (close des))
- (if (and (= 'str (type dcl)) (setq dcl (findfile dcl))) (vl-file-delete dcl))
- (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
- (princ (strcat "\nError: " msg))
- )
- (princ)
- )
- (if (and (setq dcl (vl-filename-mktemp nil nil ".dcl"))
- (setq des (open dcl "w"))
- (write-line "test:dialog{label="DCL Test";spacer;ok_cancel;}" des)
- (not (setq des (close des)))
- (< 0 (setq dch (load_dialog dcl)))
- (new_dialog "test" dch)
- )
- (if (= 1 (start_dialog))
- (princ "\nUser pressed OK.")
- (princ "\nUser pressed Cancel.")
- )
- )
- (*error* nil)
- (princ)
- )
|