Difference between revisions of "XML: Loop Using a Goto"
From FSDeveloper Wiki
(New page: {{Infobox-Applicable-FSVersion | FSXI = false | FSXA = true | FSX = true | FS2004 = true | FS2002 = false | XP10 = false | XP9 = false }} ==XML: Loop Using a Goto== A Loop can be easy ...) |
m |
||
Line 11: | Line 11: | ||
==XML: Loop Using a Goto== | ==XML: Loop Using a Goto== | ||
− | A Loop can be easy simulated using a g (goto) command which uses :''number_label'' for its target: | + | A Loop can be easy simulated using a [[g]] (goto) command which uses :''number_label'' for its target: |
<Update> | <Update> |
Revision as of 12:33, 2 September 2011
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.