I have very little XML experience and am trying to modify some existing XML code to fix a bug that sometimes results in the display of invalid wind headings. The purpose of the first 3 lines below is to calculate magnetic wind direction from true wind direction. If subtracting the magnetic variation from the true wind heading produces a negative result, 360 is added in line 2, and conversely, if the result of subtracting the variation is greater than 360, 360 is subtracted in line 3. Seems simple enough in concept. However, I would greatly appreciate it if someone could tell me why the two if{} statements in lines 2 and 3 that correct for invalid wind headings don't work. The remaining code then either displays the wind direction in degrees or in general headings like N, NE, W, etc depending on the value of DirMode. That part works (probably because I didn't write it).
I realize now that there is a macro dnor that eliminates the need for the if{} statements, but at this point I'm trying to just figure out my coding mistake(s) in lines 2 and 3.
I've asked this question elsewhere, but haven't gotten a response so far.
Thanks much,
Al
I realize now that there is a macro dnor that eliminates the need for the if{} statements, but at this point I'm trying to just figure out my coding mistake(s) in lines 2 and 3.
I've asked this question elsewhere, but haven't gotten a response so far.
Thanks much,
Al
Code:
<GaugeString>
%((A:AMBIENT WIND DIRECTION,degrees) (A:MAGVAR,degrees) - (>L:AdjDir,degrees))
%((L:AdjDir,degrees) 0 < if{(L:AdjDir,degrees) 360 + (>L:AdjDir,degrees)})
%((L:AdjDir,degrees) 360 > if{(L:AdjDir,degrees) 360 - (>L:AdjDir,degrees)})
%((L:DirMode,bool) 1 == )
%{if}
%((L:AdjDir,degrees) near)%!03d!
%{else}
%((L:AdjDir,degrees) 22.5 + 45 / int) %{case} %{:0} N%{:1}NE%{:2} E%{:3}SE%{:4} S%{:5}SW%{:6} W%{:7}NW%{:8} N%{end}
%{end}
</GaugeString>
Last edited:





