Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (25 sloc) 904 Bytes
Read and write files in Caboose.


Opening Files

Opening files in Caboose is simple. To open a file, use the with statement. The syntax of the with statement is: with(<filename>, "<mode>") {} where <filename> is a string and <mode> is a proper open mode.

with("filename.txt", "r") {
    // `file` variable passed here.

Open Modes

Open Mode Description
r Opens a file for reading, the file must exist already.
w Opens a file for writing, if a file does not exist one is created, else existing file is overwritten
a Opens a file for appending, if a file does not exist one is created, else appends text to the end of a file

File Methods


Read all lines of a file into a string.


You can’t perform that action at this time.