Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Template:Nasal Closure Wrapper

From FlightGear wiki
Jump to: navigation, search
var timers = [];
foreach(var delay; [2.0, 4.0, 8.0] ) {
#this declares an anonymous/unnamed function
(func(arg...) 
{
var interval=delay; 
var myTimer = maketimer(interval, func() {
print("Hello from the ", interval,"-second timer!");
}); # end of the embedded func
myTimer.start();
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)
 t.stop();
});
The following template description is not displayed when the template is inserted in an article.

Goal

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

Usage

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

All parameters are optional.

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

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

Technical details

This template uses {{Nasal Anonymous Func}}