XML: Loop Using a Goto: Difference between revisions
From FSDeveloper Wiki
Jump to navigationJump to search
(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 ...) |
mNo edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| 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> | ||
| Line 37: | Line 37: | ||
1. loop label can be any unique number | 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. | 2. This "loop" will execute completely on [[every]] gauge cycle (18Hz), so you may wish to "slow it down" by using a master timer. | ||
--[[User:N4gix|N4gix]] 13:35, 2 September 2011 (EDT) | |||
[[Category:Aircraft Design]] | [[Category:Aircraft Design]] | ||
[[Category:Panel and Gauge Design]] | [[Category:Panel and Gauge Design]] | ||
Latest revision as of 12:35, 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.
--N4gix 13:35, 2 September 2011 (EDT)