A capture is a block of Lasso code that can be passed to another method or invoked locally. Captures are context aware and depending on the scope have access to the current locals and self. Captures are denoted by { } brackets, by {^ ^} brackets, and are generated when using the "container" syntax. For example:
if (true)
something
/if
The above creates a capture between the if() /if.
Captures are a core component of the language and in many ways are transparent in typical usage.
{ }
{^ ^}
foo();
/foo;
Code
inline(-database='lasso_email',-table='smtp_queue',-show)
local(columns = column_names)
/inline
#columns
Result
staticarray(id, id_site, id_route, id_cache, mime_text, mime_recipients, mime_from, smtp_host, smtp_port, smtp_timeout, smtp_username, smtp_password, smtp_ssl, queue_date, queue_status, queue_error, queue_number, queue_priority, queue_retries, merge_array, merge_tokens, create_date)
Code
inline(-database='lasso_email',-table='smtp_queue',-show) => {
local(columns = column_names)
}
#columns
Result
staticarray(id, id_site, id_route, id_cache, mime_text, mime_recipients, mime_from, smtp_host, smtp_port, smtp_timeout, smtp_username, smtp_password, smtp_ssl, queue_date, queue_status, queue_error, queue_number, queue_priority, queue_retries, merge_array, merge_tokens, create_date)
Code
{ return 'hello' }->invoke
Result
hello
Code
local(i=1)
{
#i = #i + 1
#i < 10 ? currentcapture->restart
}()
#i
Result
10
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