• 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.

<visible> useage clairification

Testing for execution of the whole element using a condition and an IF section, does exactly the same as the Visibility section in an display element.

Rob,
For big chunks of code it would be better to use a quit command instead of very long if{} conditionals.

Instead of :

Code:
<Element>
   <Select>
     <Value> (or <Visible>
       (condition)
       if{
            ...
            200  lines of code
          }
     </Value>

It is preferable:

Code:
     <Value> (or <Visible>
       (condition) !
       if{ quit }
        ...
        200  lines of code
     </Value>

In the first case the parser will run over the 200+ lines of code, discarding everything down to the closing }
In the second, the script is aborted after the quit command so the rest of the code is simply ignored.
Worth especially when dealing with many huge sections iin a single gauge, separating those in <Elements> according to logical needs.

Tom
 
So can a macro contain a whole section of code (meaning tags and all)?

So using macros I can.
Code:
given L:var1=1, L:var2=2,L:var3=3

Macro Name="macro">(L:var3, number) + </Macro>

<Select>
<Value> (L:var1, number) (L:var2, number) + @macro + (&gt;L:var4, number) </Value>
</Select>

and end up with L:var4 =6 ?

Joel
Yes.
 
Rob, et al

Ie if I read an A:var value for one use in line 10 and again in line 2010 for another use it's going to have the same value ?
Yes.

and (2), Not sure if I'm getting this part right.... so are you saying if your using a key press or button/switch click to display an object or run a script, it takes 2 cycles to actually see the result? if so if your using press down for one function and release for another does it take 4 cycles? I'm confused.

Joel
I was talking about an event you give in your XML gauge code; the result of that is visible (in an Avar) in the next gauge schedule.
 
I was talking about an event you give in your XML gauge code; the result of that is visible (in an Avar) in the next gauge schedule.

Rob,

OK I get it, I think...

So does that mean you should avoid hard goto loops that depend on a change in an A:var value to end because they would not get a chance to update so would never change ?

Joel
 
Rob,

OK I get it, I think...

So does that mean you should avoid hard goto loops that depend on a change in an A:var value to end because they would not get a chance to update so would never change ?

Joel
Correct.

Other then using a "quit" in an Element section (as Tom correctly suggests in post #21), I can think of only one usefull reason to use a loop with "goto"s (as I explained in post #13) : if you want to process data in a matrix (tables) within one gauge schedule, using a "parameterised" Macro in a loop.
But tables aren't supported in XML anyway (unless you use Tom's excellent XMLTools module).
It all depends on what you are trying to code ....

Rob
 
If you study the XML script for the G500 GPS, you'll see some examples of how goto's may be usefully used within a single <Element> section.
 
Well, I'm in a holding pattern. I've been reading and looking at examples but I cannot get my code to work. The premise is to have the rectangle shift (appear as if though it's scanning across) and repeat. I've tried various placements of the goto g# and :# and still cannot get it to work. In addition, I tried using a Macro but this didn't work either. What I am doing incorrectly? The below code does not lock up but also does not execute correctly.

Code:
<Element> <Select><Value> 5 (>L:Counter_One, number) 10 (>L:Counter_Two, number) 20

(>L:Counter_Three, number) 1 (>L:OneQuarterValue, number)
</Value> </Select></Element>   

<Element> <Select><Value> :1
<Position X="60" Y="60" />
<Rectangle Width="10" Height="15" Color="black" FillColor="#ff00ff" Transparency="0.5"/>
<Axis X="5" Y="7.5"/>
<Shift><Value>
(L:OneQuarterValue, number)
</Value><Scale X="1"/>
</Shift>

(L:OneQuarterValue, number) 0.25 + (>L:OneQuarterValue, number)
(L:OneQuarterValue, number) 24 &lt; if{ g1 }
(L:OneQuarterValue, number) 24 &gt; if{ 0 (>L:OneQuarterValue, number) }

</Value> </Select>
</Element>

Also, can rectangle's, arc's, etc. parameters (i.e.: ending angle="xx") be made variable, if so, how?
 
If you use an editor that understands xml, it will highlight the errors I see.
i.e. closing 'value' without opening 'value'.
 
The reason your code didn't lock is because it couldn't even load.
You can load your .xml gauge in a web browser to check for syntax errors, if it doesn't load there it will never load in FS.
One cannot use tags "willy nilly" as you have done, illegal operations shown below -

XML:
<Element>
    <Select>
        <Value>
            <Shift>                <!-- CODE IS BAD STARTING HERE -->
                <Value>
                </Value>
            </Shift>
            <Value>
            </Value>               <!-- BAD CODE ENDS HERE -->
        </Value>
    </Select>
</Element>

An <Element> can have only 1 each of the following operational type children within it's tags - <Select>, <SelectRange>, <Shift> and <Rotate> and whatever of the operational tags are used only one set <Value> tags can be used inside of the operational tag(s). <Value> is a child element of the operational elements, only <Comment> can be a child of <Value> .

See the fsxsdk.chm in your FSX SDK folder (P3D is similar - "SimObject Creation Kit | Creating XML Gauges | Gauge Objects") or directly online at
https://docs.microsoft.com/en-us/previous-versions/microsoft-esp/cc526953(v=msdn.10)#xml-gauge-reference

For a hint to get the rectangle to work, below is working code based on yours -

XML:
<Element>
    <Position X="60" Y="60" />
        <Rectangle Width="10" Height="15" Color="black" FillColor="#ff00ff" Transparency="0.5"/>
        <Axis X="5" Y="7.5"/>
    <Shift>
        <Value>
            (L:OneQuarterValue, number) 0.25 + 25 % d r (>L:OneQuarterValue, number)
        </Value>
        <Scale X="1"/>
    </Shift>
</Element>
 
Last edited:
To Chris. Thank you for your reply. I must admit I do not know what you mean by: i.e. closing 'value' without opening 'value'. If I don't have a "pair", i.e., <Value></Value> the gauge loads up blank. This is not the case. The gauge loads fine, it just isn't executing. By the way, this is just a snippet of the gauge. Everything else is working within the gauge.

To spokes2112. Thank you for that useful information but in your code above, how do you get it to loop? That is the main goal. Also, and perhaps because it doesn't loop, the rectangle also does not move/shift, which is also the goal. And is there a way (in FS9 schema) to resize an arc or rectangle, etc.?
 
Last edited:
Thank you for that useful information but in your code above, how do you get it to loop?
The use of the modulo "%" in the <Value> formula does it, see the wiki entry here --> https://www.fsdeveloper.com/wiki/index.php?title=XML:_Increment_Variable_w/Modulo_Reset

If you want to stop it it at the last position then -
XML:
        <Value>
            (L:Rectangle_Start_Stop, bool) if{ (L:OneQuarterValue, number) 0.25 + 25 % d r (>L:OneQuarterValue, number) } els{ (L:OneQuarterValue, number) }
        </Value>

If you want stop and reset to far left then -
XML:
        <Value>
            (L:Rectangle_Start_Stop, bool) if{ (L:OneQuarterValue, number) 0.25 + 25 % d r (>L:OneQuarterValue, number) } els{ 0 }
        </Value>
 
Hello. Thank you for your reply. The information given: An <Element> can have only 1 each of the following operational type children within it's tags - <Select>, <SelectRange>, <Shift> and <Rotate> and whatever of the operational tags are used only one set <Value> tags can be used inside of the operational tag(s). <Value> is a child element of the operational elements, only <Comment> can be a child of <Value>. Was helpful, thank you.
As I stated above, I did copy the code you gave and the rectangle does not move/shift - it just 'sits" there. In the example, I had given, I was trying to see if I could get the rectangle to "strobe" across. But as I stated above, I requested help in how to use a loop/goto and if rectangles/arcs, etc. could be resized in FS9 schema, that has not been addressed yet. I appreciate your time and information though. Let me try to be a bit more clear in the goal of the loop/goto. With:
(L:OneQuarterValue, number) 0.25 + (>L:OneQuarterValue, number)
I'm trying to use this section <E><S><V> other code (L:OneQuarterValue, number) 0.25 + (>L:OneQuarterValue, number)</V></S></E> to loop and thus L:OneQuarterValue, number increments by 0.25. Currently I have to copy and paste verbatim the code shown in the previous sentence. I tried various goto's but not successful. I also tried various way to use Macros, but was unsuccessful. I need this code to repeat 220 times but I would like to avoid 220 segments of the same code, which works but is ugly, too verbose. I also am curious if having 220 segments versus a single loop has any effect on gauge speed. And of course the second goal is if generated shapes can be resized with "live" data in FS9 XML schema.
 
This is my full code which was tested and works fine in both FS9 & FSX -
It just repeats left to right, over and over...
XML:
<Element>
    <Position X="60" Y="60" />
        <Rectangle Width="10" Height="15" Color="black" FillColor="#ff00ff" Transparency="0.5"/>
        <Axis X="5" Y="7.5"/>
    <Shift>
        <Value>
            (L:OneQuarterValue, number) 0.25 + 25 % d r (>L:OneQuarterValue, number)
        </Value>
        <Scale X="1"/>
    </Shift>
</Element>

I need this code to repeat 220 times
Do not understand. Does it mean you want it to move 55 pixels? (220 * 0.25) Then what? Stop at full right? Reset to full left? A picture tells a thousand words, it may help.

Here's another code example with 3 options, also instead of working with fractional numbers (easier to deal with) in the <Value>, instead adjusted scale so that a count of 220 will equal 55 pixels. Also provided an "off" (L:Rectangle_Start_Stop, bool). Not able to test at all - my sim machine monitor blew up just yesterday. :(

XML:
<Element>
    <Position X="60" Y="60" />
        <Rectangle Width="10" Height="15" Color="black" FillColor="#ff00ff" Transparency="0.5"/>
        <Axis X="5" Y="7.5"/>
    <Shift>
        <Value>
<!-- USE ONLY ONE OF THE 2 OPTIONS -->

<!-- #1, resets to far left if turned off, otherwise repeats -->         
(L:Rectangle_Start_Stop, bool)  if{ (L:OneQuarterValue, number) ++ 221 % d r (>L:OneQuarterValue, number) } els{ 0 }
<!-- #2 , when active it counts to 220 and stops at 55px, requires a reset of (L:OneQuarterValue, number) to zero or less than 220 to start over -->
(L:OneQuarterValue, number) ++ 220 min d r (>L:OneQuarterValue, number)

        </Value>
        <Scale X="0.25"/>
    </Shift>
</Element>

And of course the second goal is if generated shapes can be resized with "live" data in FS9 XML schema.
Unknown.... The FSX SDK provides all of this but may not be available in FS9 syntax. The only ones that are available are - Arc, Pie, & Rectangle.. Pie is known not to work, see - https://www.avsim.com/forums/topic/75318-xml-pie-drawing-fs9fsx/
You can use the following keywords to search here for possible answers -
HeightScript
WidthScript
StartAngleScript
EndAngleScript

In one minute using search found this - https://www.fsdeveloper.com/forum/threads/heightscript-for-xml-rectangles.433911/post-709170
The FS9 SDK doesn't show much, some possible tags?
<HeightCode> -good
<WidthCode> -good
<StartAngleCode> -unknown
<EndAngleCode> -unknown
<LengthCode> -unknown
 
Last edited:
Hello. Does it mean you want it to move 55 pixels? (220 * 0.25). Basically , yes. But I want it to move in increments of 0.25, not just a 55 pixel shift. I copied the code above, selecting option 2 by <Comment>ing out option 1:

Code:
<Element>
    <Position X="160" Y="200" />
        <Rectangle Width="10" Height="15" Color="black" FillColor="#aaffff" Transparency="0.5"/>
        <Axis X="5" Y="7.5"/>
    <Shift>
        <Value>
<!-- USE ONLY ONE OF THE 2 OPTIONS -->

<!-- #1, resets to far left if turned off, otherwise repeats --> 
<Comment>       
(L:Rectangle_Start_Stop, bool)  if{ (L:OneQuarterValue, number) ++ 221 % d r (>L:OneQuarterValue,

number) } els{ 0 }
</Comment>
<!-- #2 , when active it counts to 220 and stops at 55px, requires a reset of (L:OneQuarterValue,

number) to zero or less than 220 to start over -->
(L:OneQuarterValue, number) ++ 220 min d r (>L:OneQuarterValue, number)
        </Value>
        <Scale X="0.25"/>
    </Shift>
</Element>

But again, the rectangle just sat there, so I don't know what you mean it worked in FS9 and FSX. I then <Comment>ed out option 2 and tried option 1, no movement/shifting was noticeable either. The shifting is important so I appreciate the help but I still am looking for assistance in using a goto loop. As I stated before, I have the code working as long as I repeat the same segment of code 220 times, I would prefer not to do that. By the way if generated shapes could be re-sized in FS9 (FS2004), I probably wouldn't need this. But if I can get it to work in FS9, then it should work in FSX. Again, thanks though.
 
A value summing 0.25 220 times = 55 , at a scale of 1 = 55 pixels
A value summing 1 220 times = 220, at a scale of 0.25 = 55 pixels
Same thing, moving 55 pixels over 220 increments.


What is (L:OneQuarterValue, number) doing? Make a <String> element to monitor it, can almost bet some other code is forcing to a static value.
A goto will not work outside of it's own element.
 
(L:OneQuarterValue, number) is doing just that, incrementing (L:OneQuarterValue, number) by 0.25. I did make a <String> element to monitor and I'm getting the number I want 55 at the end but only with 220 <Element>s of the same repetitive code. I know it's been said that a goto can only work within its own element but I cannot get it to work at all! Will keep plugging. Thanks for the help.
 
Back
Top