Template:Nasal Closure Wrapper

From FlightGear wiki
Jump to navigation Jump to search
var timers = [];
foreach(var delay; [2.0, 4.0, 8.0] ) {
#this declares an anonymous/unnamed function
var interval=delay; 
var myTimer = maketimer(interval, func() {
print("Hello from the ", interval,"-second timer!");
}); # end of the embedded func
append(timers, myTimer);
})(); # this will directly invoke the unnamed function
} # end of the foreach loop

# kill all timers
maketimer(60, func() {
foreach(var t; timers)
The following template description is not displayed when the template is inserted in an article.


This template can be used insert a Nasal snippet with an example of a function using maketimer().


{{Nasal Closure Wrapper |variable= |vector=}}

All parameters are optional.

See also Nasal Loops#for, while, foreach, and forindex loops.

Name of local variable for the foreach() loop.
Defaults to delay.
Vector for the foreach() loop.
Defaults to [2.0, 4.0, 8.0].

Technical details

This template uses {{Nasal Anonymous Func}}