Skip to content

file.open

JoeStrout edited this page Nov 16, 2026 · 4 revisions

Open a file; returns a FileHandle, or an error on failure. The default mode "r+" opens for reading and writing, creating the file if needed.

Parameters

Parameter Default Value Note
path
mode "r+"

Return value

Condition Return Value
(always) number

Notes

Example

import "file"
fh = file.open("data.txt", "r")
if fh isa error then
    print fh.message
else
    while not fh.atEnd
        print fh.readLine
    end while
    fh.close
end if

Clone this wiki locally