jmerch 发表于 2022-7-6 10:02:20

警报输入框

我搜索了我能找到的和找不到的答案。是否有一个类似于“alert”的LISP函数,但它不只是弹出框,而是让用户在那里输入一些东西(而不是在LISP中使用“prompt”?

alanjt 发表于 2022-7-6 10:14:40

您可以使用DCL/ODCL或查看DosLib,它有几个输入“警报”样式框。

Lee Mac 发表于 2022-7-6 10:24:08

我觉得写一个例子很有趣:
 

(defun PromptBox ( title msg / dcl dch file val )

;; ------------------------------------------- ;;
;; Arguments:-                                 ;;
;; ------------------------------------------- ;;
;; title - Dialog Box Title                  ;;
;; msg   - Text to Display          ;;
;; ------------------------------------------- ;;
;; Returns:-                                 ;;
;; ------------------------------------------- ;;
;; Entered String if user presses OK, else nil ;;
;; ------------------------------------------- ;;
;; Example by Lee Mac 2010-www.lee-mac.com ;;
;; ------------------------------------------- ;;

(cond
   (
   (not
       (and
         (setq dcl(vl-filename-mktemp nil nil ".dcl"))
         (setq file (open dcl "w"))
         (progn
         (write-line
             (strcat
               "promptbox : dialog { label = \"" title "\"; initial_focus = \"txt\"; spacer;"
               ": edit_box { key = \"txt\"; edit_width = 60; edit_limit = 2048; allow_accept = true; } spacer; ok_cancel; }"
             )
             file
         )
         (setq file (close file))
         (findfile dcl)
         )
       )
   )
   )
   (
   (<= (setq dch (load_dialog dcl)) 0)

   (vl-file-delete dcl)
   )
   (
   (not (new_dialog "promptbox" dch))

   (unload_dialog dch)
   (vl-file-delete dcl)
   )
   (t
   (if msg (setq val (set_tile "txt" msg)))

   (action_tile "txt" "(setq val $value)")

   (if (zerop (start_dialog)) (setq val nil))

   (unload_dialog dch)
   (vl-file-delete dcl)
   )
)

val
)或者:
 

jmerch 发表于 2022-7-6 10:36:59

好的,我试试。谢谢

Lee Mac 发表于 2022-7-6 10:45:55

 
非常欢迎JMerch-如果对代码有任何问题,请提问

jmerch 发表于 2022-7-6 10:55:16

Lee Mac 发表于 2022-7-6 11:06:34

 
You're very welcome JMerch - any questions about the code, just ask
页: [1]
查看完整版本: 警报输入框