Difference between revisions of "Goto loops"

From Scriptwiki
Jump to: navigation, search
m (changed example to a loop..)
m (heh [ ] -> [[ ]])
Line 3: Line 3:
  
 
  alias channels {
 
  alias channels {
   [var] %i , %chans  
+
   [[var]] %i , %chans  
 
   :nexti
 
   :nexti
   [inc] %i
+
   [[inc]] %i
   [if] (%i > [$chan](0)) { [return] %chans }
+
   [[if]] (%i > [[$chan]](0)) { [[return]] %chans }
 
   var %chans = %chans $chan(%i)
 
   var %chans = %chans $chan(%i)
   [goto] nexti
+
   [[goto]] nexti
 
  }
 
  }

Revision as of 00:30, 31 October 2006

You can use goto command to jump from one point to another in a script.
Goto's aren't used very much.

alias channels {
  var %i , %chans 
  :nexti
  inc %i
  if (%i > $chan(0)) { return %chans }
  var %chans = %chans $chan(%i)
  goto nexti
}