• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

{loop}{next} outside of <String>?

Messages
1,564
Country
thailand
Can {loop} {next} be used outside of <String> (for example, in an <Update> section), and if yes, can someone show an example syntax?

I would like to perform some operations within a {loop}. I'm not referring to the display of a series of values inside {loop}{next} within a <String> within an <Element>. Nor the type of loop that can be created by utilizing the gauge update cycle rate plus cycle counters and if{ statements. Rather, a loop of instructions/calculations that can be performed in the same gauge update cycle, so I am wondering if {loop} can be used outside of <String>. Make any sense?

Many Thanks.

Bob
 
Last edited:
I have same question about {case} :o

Loop can be easy simulated using a g (goto) command:
Code:
<Update>
100 sp0 (* initialize, reg.0 = loop counter, 100 cycles *)
:12345 (* loop label *)

	(* do something *)
	
l0 -- s0 0 > if{ g12345 } (* next *)
</Update>
or
Code:
<Update>
100 (>L:LoopCounter,enum)
:12345

	(* do something *)

(L:LoopCounter,enum) 1 - (>L:LoopCounter,enum)	
(L:LoopCounter,enum) 0 > if{ g12345 }
</Update>


(Note that label can be any number)
 
Last edited:
I have same question about {case} :o

Loop can be easy simulated using a g (goto) command:
Code:
<Update>
100 sp0 (* initialize, reg.0 = loop counter, 100 cycles *)
:12345 (* loop label *)

	(* do something *)
	
l0 -- s0 0 > if{ g12345 } (* next *)
</Update>
or
Code:
<Update>
100 (>L:LoopCounter,enum)
:12345

	(* do something *)

(L:LoopCounter,enum) 1 - (>L:LoopCounter,enum)	
(L:LoopCounter,enum) 0 > if{ g12345 }
</Update>


(Note that label can be any number)

Thanks Luka,

Goto and labels are not quite what I was talking about either. A single pass through those lines of code occurs each gauge update cycle and the * do something * process is allowed to continue until 100 gauge update cycles have occurred and the cycle counter reaches 100.

I was wondering about {loop}{next} as used in string display. There, a series of values can be displayed, the index pointer incremented, a new (ie, new index) series of values displayed, the index pointer incremented again, and so forth ... in one gauge update cycle.

Can the {loop}{next} construction be used outside of a <String> display?

Bob
 
Last edited:
Goto and labels are not quite what I was talking about either. A single pass through those lines of code occurs each gauge update cycle and the * do something * process is allowed to continue until 100 gauge update cycles have occurred and the cycle counter reaches 100.
Аctually, in my example * do something * is executed 100 times in EACH gauge update cycle. To check this, put a (G:Var1) ++ (>G:Var1) here and monitor the value of (G:Var1).
 
hmmm ... let me take a closer look then. Ahhh, okay ... the Goto's do the trick. :)
 
Last edited:
Yes, for/next loops and case statements can be used outside of strings, however, just like the if/then, the format is vastly different. I am not at my dev computer to post examples, but I am sue someone else will chime on with code examples.

If not, I'll dig up some code when I get home. In the mean time, the SDK has some examples, just not very good ones.

EDIT: I was trying to think about were I have used for/next loops, and realized it may always been inside a string. So I glanced at the sdk quickly on my phone, and found no reference to for/next outside of the string scripts. Sorry for my misleading statement, all these scripting languages become a blur after a while.
 
Last edited:
Thanks, Daniel. But as Luka points out, goto and label are as trivial to write as loop and next, and can accomplish the same thing - outside of strings.

Bob
 
Can {loop} {next} be used outside of <String> (for example, in an <Update> section), and if yes, can someone show an example syntax?

Good replies that suggest alternate methods that will work, but to answer the original question, no those examples are not viable outside of the <String> construct.

All {operators} are restricted to <String> constructions.

Luka's most excellent examples should be placed in the Wiki for quick future reference...

I'd suggest a title of:

XML: Loop using a Goto
 
Thanks guys. To be clear, I use this code in my xml's but it was not my idea. Someone has put a similar code many years ago, if I remember correctly, on the avsim forum.
:o

It should be put in the wiki, otherwise it will be lost again. ;)
 
Anyone can create and/or edit the Wiki!

Bill,

In your Wiki entries, how do you create the code box that displays code in the fixed width font rather than Arial which is used for the rest of the Wiki discussion?

Bob
 
Bill,

In your Wiki entries, how do you create the code box that displays code in the fixed width font rather than Arial which is used for the rest of the Wiki discussion?

Bob

Oh, that's really simple (once one has discovered it). The "secret" is to make sure that every line -including blank lines!- contains at least one leading space... :teacher:

As you can see, that also forces the Wiki to display all of the text treated with a leading space in a "light blue box" similar to what the
Code:
 tags do here in the forum.
 
Back
Top