本帖最后由 624777395 于 2024-12-4 12:25 编辑
- (defun C:E1E (/ dcl_file tmp-dcl-file-name dcl_id AA AAZ)
- ;; 创建临时DCL文件并写入对话框定义
- (setq dcl_file (open (setq tmp-dcl-file-name (vl-filename-mktemp nil nil ".DCL")) "w"))
- (foreach x
- '(
- "ZW:dialog {"
- " label = "测试窗体";"
- " :row {"
- " :edit_box { key = "AAZ"; height = 1; edit_width = 7; }"
- " }"
- " :row {"
- " :button { label = "测试"; key = "CESHI"; height = 1; }"
- " }"
- " ok_cancel;"
- "}"
- )
- (write-line x dcl_file)
- )
- (close dcl_file)
- ;; 加载并显示对话框
- (setq dcl_id (load_dialog tmp-dcl-file-name))
- (if (not (new_dialog "ZW" dcl_id))
- (progn
- (unload_dialog dcl_id)
- (exit)
- )
- )
- ;; 编辑框记忆功能
- (if (setq AAZ (vl-bb-ref 'AAZ))
- (set_tile "AAZ" AAZ) ; 对话框二次出现
- (set_tile "AAZ" "1") ; 对话框首次出现
- )
-
- (action_tile "AAZ" (vl-prin1-to-string'(
- (lambda ( / itm )
- (setq AAZ(get_tile "AAZ"))
- (vl-bb-set 'AAZ AAZ);_保存原值
- )
- )
- )
- )
- ;; 设置取消按钮的动作
- (action_tile "cancel" "(done_dialog 0)")
- ;; 设置测试按钮的动作
- (action_tile "CESHI" "(done_dialog 1)")
- ;; 启动对话框
- (setq AA (start_dialog))
- ;; 根据用户选择执行相应操作
- (if (= AA 1)
- (CHZ)
- )
- ;; 卸载对话框
- (unload_dialog dcl_id)
- ;; 清理临时文件
- (vl-file-delete tmp-dcl-file-name)
- (princ)
- )
- ;; 处理测试按钮点击后的逻辑
- (defun CHZ ()
- (setq qws (* 5 (atof(get_tile "AAZ"))))
- ;; 打印信息到命令行
- (princ (strcat "\n数值:" qws " "))
- (princ)
- )
- ;; 确保在加载时不会自动运行
- (princ)
这段代码点击测试按钮后,会提示类型错误,大佬们帮忙看看哪里出错了
|