Nasal Loops: Difference between revisions

Jump to navigation Jump to search
Line 201: Line 201:


<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
  var loopid = 0;
  var loopId = 0;
  var loop = func(id) {
  var loop = func(id) {
     id == loopid or return;          # stop here if the id doesn't match the global loop-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(loopid);      # start loop
  loop(loopId);      # start loop
  ...
  ...
  loopid += 1;        # this kills off all pending loops, as none can have this new identifier yet
  loopId += 1;        # this kills off all pending loops, as none can have this new identifier yet
  ...
  ...
  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>
</syntaxhighlight>


1,318

edits

Navigation menu