The [file->get] method returns either a single character or line depending on the [file] object's read mode. It always returns the next character or line from the current file position, which can be explicity set using the [file->setPosition] method. Note that when returning lines, each line returned does not end with a return or newline character.
local(f) = file(...)
#f->get
The following example reads the first two lines in the "test.txt" file.
Code
local(my_file) = file('/rhino/test.txt', file_openRead, file_modeLine)
#my_file->doWithClose => {^
loop(2) => {^
#my_file->get
'<br />'
^}
^}
Result
"Great Scott!"
"I know. This is heavy."
The code below outputs the first 14 characters of a file.
Code
local(my_file) = file('/rhino/test.txt')
#my_file->doWithClose => {^
loop(14) => {^
#my_file->get
^}
^}
Result
"Great Scott!"
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