(princ [expression [file-descriptor]])
Print, taking into account control characters.
This function prints to a file or to the screen. When a file-descriptor is provided, LISP prints to a file; when the file-descriptor is missing, LISP prints to the Prompt History window.
When you are printing to a file, the file must previously have been opened with the open function in write "w" or append "a" mode.
The argument expression represents the expression to be printed. It can be any expression, not just a string. The expression is printed, as well as a new line.
Unlike print and prin1, the princ function activates any control characters present within the expression. You can use the following control characters within the expression:
Control Character | Meaning |
---|---|
\\ | \ backslash character |
\" | " quote character |
\e | Escape |
\n | Newline |
\r | Return |
\t | Tab |
\nnn | Octal code nnn |
Examples
Code | Prints | Returns |
---|---|---|
(princ "\nName:") |
(new line) Name: |
"\n Name:" |
|
||
(setq a "Address: ") | ||
(princ a) | Address: | "Address: " |
(princ 'a) | A | A |
(princ "Telephone: " f) | Telephone: (to file f) | "Telephone: " |
NOTE The difference between the princ function and LISP's other print-related functions (for example, print and prin1) is that princ acts upon control characters.
Tell me about...
(setq symbol1 statement1 [symbol2 statement2] ...)