About Displaying Messages (AutoLISP)

 
 
 

AutoLISP programs often need to inform the user of an error or request for input.

Messages that are displayed should try and not interrupt the flow of a command, and when they do the text displayed should be short and precise as to what the problem is or the input that is being requested. AutoLISP offers the following functions to display messages to the user:

The write-char, write-line, getXXX, and entsel functions can also display messages at the AutoCAD Command prompt.

When entered from the Visual LISP Console window prompt, the prompt function displays a message (a string) in the AutoCAD Command window and returns nil to the Visual LISP Console window. The princ, prin1, and print functions all display a value (not necessarily a string) in the AutoCAD Command prompt and returns the value to the Visual LISP Console window.

NoteVisual LISP is available on Windows only.

The following examples demonstrate the differences between the basic output functions and how they handle the same string of text.

(setq str "The \"allowable\" tolerance is \261 \274\"")
(prompt str) outputs The "allowable" tolerance is 1/4"
returns nil

(princ str) outputs The "allowable" tolerance is 1/4"
returns "The \"allowable\" tolerance is 1/4\""

(prin1 str) outputs "The \"allowable\" tolerance is 1/4""
returns "The \"allowable\" tolerance is 1/4\""

(print str) outputs<blank line> "The \"allowable\" tolerance is 1/4""<space>
returns "The \"allowable\" tolerance is 1/4\""