Prints an expression to the command line or writes an expression to an open file
(prin1 [expr [file-desc]])
The value of the evaluated expr. If called with no arguments, prin1 returns a null symbol.
Used as the last expression in a function, prin1 without arguments prints a blank line when the function completes, allowing the function to exit “quietly.”
Command: (setq a 123 b '(a))
(A)
Command: (prin1 'a)
AA
The previous command printed A and returned A.
Command: (prin1 a)
123123
The previous command printed 123 and returned 123.
Command: (prin1 b)
(A)(A)
The previous command printed (A) and returned (A).
Each preceding example is displayed on the screen because no file-desc was specified. Assuming that f is a valid file descriptor for a file opened for writing, the following function call writes a string to that file and returns the string:
Command: (prin1 "Hello" f)
"Hello"
If expr is a string containing control characters, prin1 expands these characters with a leading \, as shown in the following table:
Control codes |
|
---|---|
Code |
Description |
\\ |
\ character |
\" |
" character |
\e |
Escape character |
\n |
Newline character |
\r |
Return character |
\t |
TAB character |
\ nnn |
Character whose octal code is nnn |
The following example shows how to use control characters:
Command: (prin1 (chr 2))
"\002""\002"
-
Displaying Messages in the AutoLISP Developer's Guide.