read-line (AutoLISP)

Reads a string from the keyboard or from an open file, until an end-of-line marker is encountered

Supported Platforms: Windows and Mac OS

Signature

(read-line [file-desc])
file-desc

Type: File

A file descriptor (obtained from open) referring to an open file. If no file-desc is specified, read-line obtains input from the keyboard input buffer.

Return Values

Type: String

The text read by read-line, without the end-of-line marker. If read-line encounters the end of the file, it returns nil.

Examples

Windows

Open a file for reading:

(setq f (open "c:\\my documents\\new.tst" "r"))
#<file "c:\\my documents\\new.tst">

Use read-line to read a line from the file:

(read-line f)
"To boldly go where nomad has gone before."

Obtain a line of input from the user:

(read-line)
To boldly go
"To boldly go"
Mac OS

Open a file for reading:

(setq f (open "/my documents/new.tst" "r"))
#<file "/my documents/new.tst">

Command:

Use read-line to read a line from the file:

(read-line f)
"To boldly go where nomad has gone before."

Obtain a line of input from the user:

(read-line)
To boldly go
"To boldly go"