The [dir->forEach]
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 string containing the name of the item. (Names of directories will have a trailing slash.)
local(d) = dir(...)
#d->forEach => {
#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