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

XML synthax difficulty

Messages
371
Country
france
Hi,

Excuse me for my bad english, but I am french...

I have decided to adapted au gauge to an aircraft and my knowledge in xml language is very very poor.

I have many diffucult to unsdertand the contionals synthax in xml.

The only language of programming that I have used in past is Visual Basic 6

So, I would like to know how write a multiple condition line :

I am writing for in my Visual basic logic with () for you can understand the result that I expect

If (a=x1 AND B=y1) OR (a=x2 AND b=y2) OR (a=x3 AND b=y3 THEN .....

IF (TOTAL WEIGHT > 66000 AND Flaps Handle Index = 4) OR ( 66000 < TOTAL WEIGHT < 63000 AND Flaps Handle Index = 3 ) OR ( 65000 < TOTAL WEIGHT < 60000 AND Flaps Handle Index = 2 ) THEN

I am probably a stupid boy but I don't find the solution in xml; XML is very "special" :eek:

Is this redaction is the right thing ?

<Visibility>(A:TOTAL WEIGHT, kilograms) 66000 &gt;= (A:Flaps Handle Index, number) 4 == &amp;&amp; (A:TOTAL WEIGHT, kilograms) 63000 &gt;= (A:TOTAL WEIGHT, kilograms) 66000 &lt; (A:Flaps Handle Index, number) 3 == &amp;&amp; (A:TOTAL WEIGHT, kilograms) 60000 &gt;= (A:TOTAL WEIGHT, kilograms) 65000 &lt; (A:Flaps Handle Index, number) 2 == &amp;&amp; ||</Visibility>
 
Salut,
tu y etais presque. Il ne manquaient que deux "and".
Ces deux-la se trouvaient d'ailleurs implicites dans ta logique Infix:
66000 < TOTAL WEIGHT < 63000 equivaut a ( TW >= 63000 ) AND ( TW < 66000 )
Je pense que tu as tres bien compris le systeme.

Code:
(A:TOTAL WEIGHT, kilograms) 66000 &gt;= 
(A:Flaps Handle Index, number) 4 == and 

(A:TOTAL WEIGHT, kilograms) 63000 &gt;= 
(A:TOTAL WEIGHT, kilograms) 66000 &lt; [B]and[/B] 
(A:Flaps Handle Index, number) 3 == and 
or
(A:TOTAL WEIGHT, kilograms) 60000 &gt;= 
(A:TOTAL WEIGHT, kilograms) 65000 &lt; [B]and[/B] 
(A:Flaps Handle Index, number) 2 == and 
or

Je me suis aussi permis de remplacer les "&amp;&amp;" par "and", et "||" par "or", ce que je trouve beaucoup plus lisible. Mais cela est une question de preferences.

Cdlmt,

Gunter

Note: I hope the moderators and public don't mind this small infringement to the forum rules. :o
 
Last edited:
Merci beaucoup Gunter !!!

Thank you very much Gunter !!

Dernière question, est ce que l'on peut presenter le code écrit comme le tieet, c'est à dire en faisant des retour à la ligne, ou faut-il que tout soit sur la même ligne ?

Can I write my code with CR like you Gunter, or All the instruction must be on the same line ?
 
This:
Code:
(A:TOTAL WEIGHT, kilograms) 63000 &gt;= 
(A:TOTAL WEIGHT, kilograms) 66000 &lt; and
could also be written like this:
Code:
63000 66000 (A:TOTAL WEIGHT, kilograms) rng
The above will be TRUE if the variable is within the range (rng) of the two parameters.

Corrected syntax: thanks for the catch, Luka!
 
Last edited:
Merci beaucoup Gunter !!!

Thank you very much Gunter !!

Dernière question, est ce que l'on peut presenter le code écrit comme le tieet, c'est à dire en faisant des retour à la ligne, ou faut-il que tout soit sur la même ligne ?

Can I write my code with CR like you Gunter, or All the instruction must be on the same line ?
Liberal use of CR and TAB in the code is not only possible, but highly recommended for better lisibility of the code.

(Note that the following is only true for logic code inside of tags.)

AFAIK (and anybody please jump in here if this is wrong!) CR and TAB have NO effect on code execution. (Of course you shouldn't do something stupid like cut an operator or variable in two with a CR.)

Spaces on the other hand DO have an important impact, and have to be placed at the right place.
Spaces separate operator, variables ect. There must be a space between each such element.
A missing space can kill the complete code.
A space or two too much on the other hand rarely (never?) hurts (again, unless one does something stupid like cut an operator in two with a space: "if{" = good; "if {" = bad).

When splitting code into several lines with CR, I nevertheless take a few precautions to avoid to forget to place a required space at a required place.
In particular I systematically place a space at the end of each line of complex code inside a tag (except inside strings of course).
In 95% of lines this will be superfluous, and I'm not even sure whether a line that doesn't end with a space is ever a problem, but I just feel more at ease not to run into problems that are lengthy to troubbleshoot at some point.

I've made the hard experience that FS xml syntax is no place for experimentation...
If I've got a method to get consistent and reliable results I'll doggedly stick to it. Too much time spent troubbleshooting.
 
Last edited:
I think this should be:
Code:
63000 66000 (A:TOTAL WEIGHT, kilograms) rng


I was just going to say, you have to put the amounts before the brackets and rng after the brackets or bent line things, what ever they are called. :D I tried it both ways in FS9 and they only work as written by Luka.
 
I've made the hard experience that FS xml syntax is no place for experimentation...
If I've got a method to get consistent and reliable results I'll doggedly stick to it. Too much time spent troubbleshooting.

Gunter

Amen to that. I have spent days just trying to get something so massively simple to work... arrgh...

Sometimes you can write it in 20 or 50 different ways, but only one, maybe two ways will work.
 
I think this should be:
Code:
63000 66000 (A:TOTAL WEIGHT, kilograms) rng

Corrected syntax in my post to prevent any further confusion. Thanks for the catch, Luka!

The "rng" operator will evaluate to TRUE if the third parameter (the A:var in this case) falls within the range of the first and second parameters.
 
Thank you for your responses and your times;

I try this code :

<Visibility>
46000 58000 (A:TOTAL WEIGHT, kilograms) rng (A:Flaps Handle Index, number) 4 == AND
56000 60000 (A:TOTAL WEIGHT, kilograms) rng (A:Flaps Handle Index, number) 3 == AND OR
52000 57000 (A:TOTAL WEIGHT, kilograms) rng (A:Flaps Handle Index, number) 2 == AND OR
</Visibility>

And it don't works.

I want to verify (condition A) OR (condition B) OR (Condition C) ---> if one of this condition is right then execute

I want to show on the PFD the Vr; this exemple is for Speed 130 Bar strip image



I am an desesperate FSXhouseman
 
Last edited:
Well, no it won't work because you capitalized the conjunction operators...

Try this instead:

Code:
<Visibility>
46000 58000 (A:TOTAL WEIGHT, kilograms) rng (A:Flaps Handle Index, number) 4 == and
56000 60000 (A:TOTAL WEIGHT, kilograms) rng (A:Flaps Handle Index, number) 3 == and or
52000 57000 (A:TOTAL WEIGHT, kilograms) rng (A:Flaps Handle Index, number) 2 == and or
</Visibility>
 
Last edited:
Thank you very much N4gix !

It works perfectly !

thanks at all people

Have a good day/night
 
Well, no it won't work because you capitalized the conjunction operators...

Try this instead:

Code:
<Visibility>
46000 58000 (A:TOTAL WEIGHT, kilograms) rng (A:Flaps Handle Index, number) 4 == and
56000 60000 (A:TOTAL WEIGHT, kilograms) rng (A:Flaps Handle Index, number) 3 == and or
52000 57000 (A:TOTAL WEIGHT, kilograms) rng (A:Flaps Handle Index, number) 2 == and or
</Visibility>



Dang... I didnt know you could stack those like that!?

Learn something new everyday... Saving this to the archives...
 
Dang... I didnt know you could stack those like that!?
I assume you are referring the the use of "and or" in that example. Be very careful to understand that the use of "or" in this specific case is only tieing the three major (condition) statements together as three "alternate cases."

By that I mean:
if
(conditional 1 results are TRUE)
or
(conditional 2 results are TRUE)
or
(conditional 3 results are TRUE)
then
the entire evaluation set is TRUE
else
the entire evaluation set is FALSE

Another way of putting it is that those "or" conjunction operators only affect the results of the major conditional evaluations, and not the individual components of the major conditional evaluations.
 
Hello,

I have a last problem.

Most FSX's jet have a Auto pilot issue in my opinion. When you climb with Autopilot ON and A/THR, your are in IAS mode in first.

So, near 20 000/ 25000 ft, I would must turn on speed mode in Mach mode.

For exemple :

I am at 20 000ft and 300 kias. I want to go to 30000ft. I set the altimeter and The Vertical rotative button to right value, and I press speed button to show mach value on the panel; and I set the mach to 0.77 with the rotative button.
So, FSX doesn't refresh the speed while aircraft climb. et when I arrived to 30000ft, panel indicator show M 0.77, but the plane is at M 0.86 or 87, because, It keep in memory the ration MAch/IAS of the altitude where I have set the speed.
It is really a issue in my opinion.

So, I would like to modify that. I would like to refresh the airspeed select (ias) with the altuitude when climb.

I have try to add this code in the pfd.xml gauge, but it doesn't work.

Code:
<Update id="MACHCONTROL">
     <Script>
(A:Autopilot Mach Hold, bool) 1 == (A:Plane Altitude, feet) 20000 &gt; and
(A:Airspeed Mach, mach) (A:Autopilot Mach Hold Var, number) &gt; and and
 if { 1 (>K:AP_SPD_VAR_DEC) }
     </Script>
</Update>

Have you an idea to refresh selected IAS speed in mach mode with altitude variable ?
 
Tom, that is most likely the problem. The number of conjunctions (and/or) are normally the [number of (conditions) - 1]...

...but the number of conditions isn't always as clear as simply things that have parenthesis around them!

What's confusing to most is that the conjunctions are trailing after a pair of conditions, instead of being in-between the conditions, hence instead of...

(condition1) and (condition2)

the correct syntax is...

(condition1) (condition2) and

Even more confusing is that it is legal to put most of the conjunctions at the end of the list of conditions, which makes parsing out the actual logic damn near impossible!

For example:

(condition1) (condition2) and (condition3) (condition4) (condition5) and and or

This parses out to:

(condition1) and (condition2)
or
(condition3) and (condition4) and (condition5)

It is for this very reason that I make a habit of placing the conjunctions after each pair of (conditionn) statements! :D

In the example in the original post, the last two items are -when taken together- only one (condition)! The presence of the &gt; (greater than) is the needed clue. This makes the final conjunction "and" unnecessary, and quite likely enough of an error to cause the entire chain of logic collapse in a shuddering heap...
 
Last edited:
Thank you for your answers. I will try to change the code in this direction.

Why did they not choose the syntax of BASIC for the gauges (at least for conditional tests) and is much easier !

IF c1=c2 AND c3>c4 AND c5>c6 THEN
{execute code 1}
ELSE
{execute code 2}
END IF

I would never amount to anything with this XML code ! :mad:
 
For a computer this is much simpler and faster calculator than BASIC.
 
Back
Top