Function Definitions

 11  -  Printing to Screen


Summary:
 
Accepts both
strings and
numbers
Prints 
control 
characters
Prints new 
line and 
trailing space
Quotation 
marks for 
strings
Returns 
(when 
printing 
strings)
prin1 yes verbatim no "xxxxxx" "xxxxxx"
princ yes interpreted no xxxxxx "xxxxxx"
print yes verbatim yes "xxxxxx" "xxxxxx"
prompt strings only interpreted no xxxxxx nil

prin1 ..... Prints an expression (string or numbers) on the screen or to a file and returns the expression

(prin1 'a)  prints A and returns A
(prin1 "hello")  prints "hello" and returns "hello"
After (setq a 15.9 b "good bye")
(prin1 a)  prints 15.9 and returns 15.9
(prin1 b)  prints "good bye" and returns "good bye"
(prin1 b fw)  prints "good bye" to the file buffer identified by variable fw (assuming it has already been opened for writing) and returns "good bye"
(prin1 (chr 10))  prints "\n" verbatim and returns "\n"
(prin1)  returns nothing. Can be used as the last function in a program to cancel the display of "nil" or other extraneous output.


princ ..... Similar to prin1 (see prin1 above) except control characters such as (chr 10) are interpreted when printed rather than printed verbatim

The following control characters will function as described when made part of a string (included in quotation marks):
  \n carriage return and line feed (new line)
  \r carriage return only (cursor stays on same line)
  \t tab every 8 columns (9th, 17th, 25th, etc.)
  \\ single backslash (useful for path names - or, a single forward slashes can be used in path names)
  \e escape character (useful for sending escape codes to a printer, etc.)
  \xxx character whose octal (base 8) code is xxx


print ..... Same as prin1 except the printed expression is preceded by a carriage return and line feed and followed by a space

prompt ..... Displays a string on the screen and returns nil, accepts only strings, and interprets control characters.

(prompt "Dog yummies")  displays  Dog yummies  on the screen


terpri ..... Prints a new line on the screen

(terpri)  prints carriage return and line feed, returns nil (not used for file output)


HOME


Copyright © 1988, 1998 Ronald W. Leigh