20,741
edits
| Line 82: | Line 82: | ||
| This can be solved by providing each loop chain with a ''loop identifier'' and letting the function end itself if the id doesn't match the global loop-id. Self-called loop functions need to inherit the chain id. So, every time the global loop id is increased, all loop chains die, and a new one can immediately be started. | This can be solved by providing each loop chain with a ''loop identifier'' and letting the function end itself if the id doesn't match the global loop-id. Self-called loop functions need to inherit the chain id. So, every time the global loop id is increased, all loop chains die, and a new one can immediately be started. | ||
| <syntaxhighlight lang="php"> | |||
|   var loopid = 0; |   var loopid = 0; | ||
|   var loop = func(id) { |   var loop = func(id) { | ||
| Line 94: | Line 95: | ||
|   ... |   ... | ||
|   loop(loopid);       # start new chain; this can also be abbreviated to:  loop(loopid += 1); |   loop(loopid);       # start new chain; this can also be abbreviated to:  loop(loopid += 1); | ||
| </syntaxhighlight> | |||
| [[List_of_Nasal_extension_functions#settimer.28.29|More information about the settimer function is below]] | [[List_of_Nasal_extension_functions#settimer.28.29|More information about the settimer function is below]] | ||