Some simple formatting of text can be handled through the use of expanded ASCII codes or control codes. We have already seen one of these, “\n”, which generates a new line. Here are some others that may be useful.
Note that multiple control codes can be used within the same string.
- The control codes must be within the double quotes.
- The control codes must be lowercase.
Command: (prompt “This text \nis on \nthree lines with a \ttab.”)
three lines with a tab.nil
Translating ASCII Codes
Two other functions will help you work with specialty ASCII characters.
Changes the string to the appropriate ASCII character as an integer.
Changes the integer to the appropriate ASCII string.
Command: (ascii “N”)
Command: (chr 78)
Open the drawing file BLOX.DWG and then edit the LISP file BOM.LSP so that there is a title showing “Number” and “Name”, the prompts are joined together with (strcat), and there are tabs between the information so that the returned information is easier to read.
(defun c:BOM ()
(setq BLK-INFO (tblnext “BLOCK” T))
(prompt “\n NUMBER \t\tNAME”)
(setq BLK-NM (cdr (assoc 2 BLK-INFO)))
(setq SS1 (ssget “X”
(list (cons 0 “INSERT”)
(cons 2 BLK-NM)
) ;_ end of list
) ;_ end of ssget
) ;_ end of setq
(setq COUNT (sslength SS1))
(setq COUNT 0) ) ;_ end of if
(prompt (strcat “\n \t” (itoa COUNT) “\t \t” BLK- NM))
(setq BLK-INFO (tblnext “BLOCK”))
) ;_ end of while
) ;_ end of defun