XML: Loop Using a Goto: Difference between revisions
From FSDeveloper Wiki
Jump to navigationJump to search
mNo edit summary |
mNo edit summary |
||
| 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)