ReadArray()
Summary
Reads a text file into an array of strings.
Syntax
result = ReadArray(file fptr)
| Argument | Contents |
|---|---|
| fptr | A file handle |
Returns
An array of strings, one for each line in the file.
Notes
-
ReadArray() reads each line in the file as a single string.
-
Zero length strings (e.g., a blank line in the input file) are represented as null elements in the array.
-
Use LoadArray() to load an array saved in a binary format by SaveArray().
Example
ptr = OpenFile("listfile.txt", "r")
a = ReadArray(ptr)
CloseFile(ptr)
Error Codes
| Error Type | Meaning |
|---|---|
| Error | File is not open, is open in the wrong mode, or is a binary file |
See Also
| Function | Summary |
|---|---|
| LoadArray() | Loads an array from a file |
| OpenFile() | Opens a text or binary file on disk |
| ReadSizedArray() | Reads a group of strings from a file |
| WriteArray() | Writes the elements of an array to a text file |
| WriteArraySeparated() | Writes the elements of an array to a file, separated by a delimiter |