Another example 1·(L:XMLVAR_YokeHidden1,·Number)·-·(>L:XMLVAR_YokeHidden1,·Number)
There are a ton of resources about the MS flightsim RPN scripting - even when they are 15 years old, they are still valid. TMBK the MSFS SDK documentation doesn’t cover this yet, but the Prepar3D SDK documentation is accessible online. Google for “P3D RPN scripting”, or “FSX XML gauges”, visit fsdeveloper or just search for the variable name that you want to handle in the script. This type of coding has been used in the MS XML gauges for almost 20 years, that is why it was chosen for programming purposes in AAO.
As for your example above - this is RPN, so postfix notation. Postfix is how a computer actually works, and it was very common when computers were still young.
Simply put:
- Code is written stack-oriented: push value, push value, call operand/calculation etc.
- Nothing of the high-level programming languages like Javascript exists.There are no classes, objects, procedures, functions…
- “(L:” is the getter method
- “(>L:” is the setter method.
- This goes for all variables, A, H, too
Something must be on the stack to be set to the variable, so “something” is required before the setter is called.
1·(L:XMLVAR_YokeHidden1,·Number)·-·(>L:XMLVAR_YokeHidden1,·Number)
converted into infix notation is
L:XMLVAR_YokeHidden1 = 1 - L:XMLVAR_YokeHidden1;
Why do I do this? Because it is supposed to be a toggle. The LVar is 0 or 1 and the value determines if you can see the yoke or not. So when it is visible, I set 1-0 = 1 to the LVar, and it disappears. Calling the script again will set 1-1 = 0 to the Lvar and the yoke reappears.
Split into two separate scripts (for an ON button and an additional OFF button):
1 (>L:XMLVAR_YokeHidden1, Number)
hides the yoke
0 (>L:XMLVAR_YokeHidden1, Number)
makes it appear