Within quoted string values, the backslash (\) character allows control characters (or escape codes) to be included.
The following lists the currently recognized control characters:
AutoLISP control characters |
|
---|---|
Code |
Description |
\\ |
\ character |
\" |
" character |
\e |
Escape character |
\n |
Newline character |
\r |
Return character |
\t |
Tab character |
\ nnn |
Character whose octal code is nnn |
The prompt, princ, and getXXX functions expand the control characters in a string and display the expanded string at the AutoCAD Command prompt.
The following example shows displaying a backslash character (\) and quotation mark (") within a quoted string:
(princ "The \"filename\" is: D:\\ACAD\\TEST.TXT.") The "filename" is: D:\ACAD\TEST.TXT
Text can be forced across multiple lines with the newline character (\n).
(prompt "An example of the \nnewline character. ") An example of the newline character.
You can also use the terpri function to cause a line break.
The Return character (\r) returns to the beginning of the current line. This is useful for displaying incremental information (for example, a counter showing the number of objects processed during a loop).
A Tab character (\t) can be used in strings to indent or to provide alignment with other tabbed text strings. In this example, note the use of the princ function to suppress the ending nil.
(prompt "\nName\tOffice\n- - - - -\t- - - - - (_> \nSue\t101\nJoe\t102\nSam\t103\n")(princ) Name Office - - - - - - - - - - Sue 101 Joe 102 Sam 103