XML script: What's the max stack depth?

Thanks goes out Tom Gibson for this question...

I didn't know this one off the top of my head, so I first cheated by looking at the source code for the stack calculator in FS and then verified te answer by doing a simple experiment.  I put the following script in a Text element and tried out the gauge, starting with:. 

%( 1 1 1 
+ + 
)%!d!

which yielded 3, as expected:

I then added 1's and +'s until the result was not what I expected.

%( 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
+ + + + + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + + + + 
)%!d!

There are 32 1's and 31 +'s in the script above, which should give us a result of 32, or the max stack depth allowed, whichever is smaller, right?  The result that showed up on-screen was:

[Missing image]

Aha!  So the max stack depth is 30!

But to alleviate any fears out there, no, you cannot "blow the stack" in script.  You will not cause Flight Sim to come crashing down on top of you (or someone using your gauge) if you create a stack deeper than that.  But your script probably won't function as you expect, as you can lose values that you have put on it!

This may seem like a far-fetched scenario, but if you look at the script for the GPS 500 that ships with FS9, you'll see places where the "case" operator is used on a stack of 25 items, which certainly isn't too far from our max of 30!  Perhaps we should have mentioned this in our SDK documentation somewhere...

 [:$]