XML: Loop Using a Goto
From FSDeveloper Wiki
XML: Loop Using a Goto
A Loop can be easy simulated using a g (goto) command which uses :number_label for its target:
<Update>
100 sp0 (* initialize, reg.0 = loop counter, 100 cycles *)
:12345 (* loop label *)
(* do something *)
l0 -- s0 0 > if{ g12345 } (* next *)
</Update>
An alternative to using the stack pointer operators (and makes the script more clear!) is this form:
<Update>
100 (>L:LoopCounter,enum) (* initialize the counter's stack, 100 cycles *)
:12345 (* loop label *)
(* do something *)
(L:LoopCounter,enum) 1 - (>L:LoopCounter,enum) (* decrement -1 *)
(L:LoopCounter,enum) 0 > if{ g12345 } (* next *)
</Update>
Notes:
1. loop label can be any unique number 2. This "loop" will execute completely on every gauge cycle (18Hz), so you may wish to "slow it down" by using a master timer.
--N4gix 13:35, 2 September 2011 (EDT)