Skip to content

dos_readtextfile

Dale Fugier edited this page Jul 1, 2026 · 1 revision

Reads a text file from disk and returns the text as a list of strings. ANSI, UTF-8 and Unicode encoded text files are supported.

Syntax

(dos_readtextfile [filename [ignore_empty [trim_spaces]])

Parameters

filename

The name of an existing text file to read.

ignore_empty

If omitted or nil, then if an empty line in the file is encountered, a nil element will be added to the list. If T, then empty lines will be ignored.

trim_spaces

If omitted or nil, then leading and trailing spaces, for each line in the file, will not be trimmed. If T, then leading and trailing spaces will be trimmed.

Returns

A list containing one or more lists if successful.

nil on error.

Example

Command: (dos_readtextfile "test.txt")
("The quick brown fox" "jumped over the lazy dog.")

Clone this wiki locally