Function: open

The open function allows you to open a filesystem file for read, write, or write-append access.

Parameters:

Parameter Name Type Description
Filename string Full path or relative path of the file. Use ~ to refer to the user's home folder.
Access Mode string Either "r" (read), "w" (write), or "wa" (write append) mode.

Return Value:

Type Int: An integer number representing the open file, which can be used as a parameter in subsequent function calls to write more bytes to the same file.

Example:

int x = open("myFile.txt", "w");
write(x, "This is a line of text to the file");
write(x, format("\nHere are some data, %s, %d, %s, %d", "data1", 22, "data2", 33));
close(x);

Related: