# Some Basic XML Gauge Questions

## Recommended Posts

I am new to both XML and FSX gauges and have been looking at existing code as a learning exercise. In this regard, I have some questions about the small code segment below which is from the default FSX CRJ-700 pfd.xml file (if this is not the best place for this, moderator please delete post).

```<Element id="Altitude Strip">
<FloatPosition>0.000,0.000</FloatPosition>
<Image id="pfd_altitude_strip.bmp" Name="pfd_altitude_strip.bmp">
<Transparent>True</Transparent>
<Axis>-19.000,498.000</Axis>
<Bright>True</Bright>
</Image>
<Axis>0.000,72.000</Axis>
<Shift id="Shift">
<Scale>0.000,0.327</Scale>
<Expression id="Expression">
<Minimum>-2000.000</Minimum>
<Maximum>1000.000</Maximum>
<Script>
(P:Units of measure, enum) 2 ==
if{ (A:Indicated Altitude:1, meters) }
els{ (A:Indicated Altitude:1, feet) }
99999 min -9999 max s0 1000 % flr
s1
l0 1000 <
if{ l1 1000 - } els{ l1 }
</Script>
</Expression>
<FailureTable id="FailureTable">
<Failure id="Failure">
</Failure>
</FailureTable>
</Shift>
```
My interpretation of the Shift code is the vertical movement of the altitude strip will be scaled (multiplied) by 0.327 and the min and max movement in pixels is -2000 to +1000 (after scaling or before?), or is it the "answer" from the Script calculation that will be scaled by 0.327?  Then assuming we are dealing with altitude in feet, we check to make sure the altitude is between -9999 and 99999 ft. Why consider an altitude of -9999ft? The altitude is then stored in register s0, and we calculate a modulo 1000 value rounded down by the flr operation. The result, which must be less than 1000, is stored in register S1. That value from S0 (original altitude) is then pushed on the stack and we ask if it is less than 1000. If so we subtract 1000 from it which gives a negative number ( I don't understand what this negative number represents or how it will be used unless it means move the strip down?).  If the original altitude is not less than 1000, we end up with the modulo value (which is less than 1000) from S1 which I believe is the "hundreds of feet" component of the altitude.  Am I interpreting the Script correctly? Maybe I don't clearly understand the big picture regarding this code block.

Finally, what is a Failure  Table?

Thanks very much for any help.

Al

Edited by n4gix
Placed script in Code Box

##### Share on other sites
 Help AVSIM continue to serve you!Please donate today!

## Create an account

Register a new account

• Tom Allensworth,
Founder of AVSIM Online

• ### Hot Spots

• Flight Simulation's Premier Resource!

AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!