The [file->forEachLine] method takes a block of code that will be executed for each line in the file the [file] object refers to. Inside the block you can access the current line using the special local variable #1 which will be a byte stream containing a line from the file.
local(f) = file(...)
#f->forEachLine => {
#1
}
The code below will output the contents of a Lasso source file as an ordered list.
Code
local(my_file) = file('index.lasso')
handle => {#my_file->close}
'<ol>'
#my_file->forEachLine => {^
'<li>' + string(#1)->encodehtml + '</li>'
^}
'</ol>'
Result
- <?=
- library_once('/_config/conf.lasso')
- date
- ?>
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