The [file->close] method closes the connection to a file that has been opened by a [file] object. This method should be called whenever a file operation is finished.
local(f) = #file(...)
#f->openRead
#f->close
The code below reads the contents of a file and outputs it to a web page encoding the line breaks as '<br />' tags. I have the call to the [file->close]
method in a [handle] block because I want that code to be executed if either the code fails or succeeds to run.
Code
local(my_file) = file('test.txt')
handle => { #my_file->close }
encode_break(#my_file->readBytes->asString)
Result
"Great Scott!"
"I know. This is heavy."
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments