The [dir->forEachEntry]
method takes a block of code that will be executed for each item in the folder the [dir]
object refers to. Inside the block you can access the current item using the special local variable #1
which will be a [pair]
whose first element is the name of the item and whose second element is an integer which flags the item as a file, folder, symbolic link, etc.
local(d) = dir(...)
#d->forEachEntry => {
#1
}
The code below will display the list of items in the web root as an un-ordered list. For purposes of the result, assume the web-root contains the following items: 'css/', 'img/', 'index.lasso', 'js/', and 'test.lasso'
Code
local(web_root) = dir('/')
'<ul>'
#web_root->forEachEntry => {^
'<li>' + #1->first + '</li>'
^}
'</ul>'
Result
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