1,318
edits
| Line 201: | Line 201: | ||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> | ||
var | var loopId = 0; | ||
var loop = func(id) { | var loop = func(id) { | ||
id == | id == loopId or return; # stop here if the id doesn't match the global loop-id | ||
... | ... | ||
settimer(func { loop(id) }, 2); # call self with own loop id | settimer(func { loop(id) }, 2); # call self with own loop id | ||
}; | }; | ||
loop( | loop(loopId); # start loop | ||
... | ... | ||
loopId += 1; # this kills off all pending loops, as none can have this new identifier yet | |||
... | ... | ||
loop( | loop(loopId); # start new chain; this can also be abbreviated to: loop(loopId += 1); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
edits