Fuego.Io : TextFile

The TextFile component creates, reads from and writes to text files.

TextFile iterations allows for line-by-line processing of a text file.

Example 1

In the following example, the Textfile component creates and writes lines to a text file:

textFile = TextFile()

openForWriting textFile
    using name = "/tmp/MyFile.txt",
    append = true

for each textString in ["This is line 1","This is line 2", "This is line 3"]
do
    writeLineTo textFile using textString
end
close textFile

Example 2

In the following example, the Textfile component is used to read lines from a text file:

textFile = TextFile()

open textFile
    using name = "/tmp/MyFile.txt"

display ("Does file exist? " + textFile.exists)
 
for each line in textFile.lines
do
    display line
end
 
close textFile