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

Files

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.
    println(file.read());
}

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()

Read all lines of a file into a string.

Signature:

string file.read()
You can’t perform that action at this time.