Another example, similar to Gile's:
(defun PromptBox ( title msg / dcl dch file val )
;; ------------------------------------------- ;;
;; Arguments:- ;;
;; ------------------------------------------- ;;
;; title - Dialog Box Title ;;
;; msg - [Optional] 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
)