(read-char [file-descriptor])
Read a single character.
This function reads a single character from the file or keyboard. When a file-descriptor is included (as assigned by the openfunction), read-char reads from a file. When file-descriptor is missing, read-char reads from the keyboard. ]
The read-char function doesn't actually return the letter, rather it returns the ASCII code of that letter. To actually see the letter, you must convert the ASCII code using the chr function.
Examples
For the following example, assume the file sample.lsp exists, and the first line is "C:\Sample\First.txt".
Code | Returns |
---|---|
(setq file (open "sample.lsp" "r")) | |
(setq c (read-char file)) | 67 |
(setq a (chr c)) | "C" |
(read-char) [press A] |
Waits for you to press a key. 65 |
Tell me about...
(setq symbol1 statement1 [symbol2 statement2] ...)