Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How are macros used in xml?

Featured Replies

In the post concerning modulus in this forum I found a perfect macro for the rolling numbers I want to have that will show elapsed run time on my Tachometer. Can someone explain how to use macros?Thanks!Robert

Best Regards,
Robert Kerr

3D Modeler & Texture Artist
 

Probably the best place to learn about macros is to tear appart the default GPS and look at the way it does things. I have pulled a variety of usefull functions from it.CheersShad

  • Moderator

>In the post concerning modulus in this forum I found a>perfect macro for the rolling numbers I want to have that will>show elapsed run time on my Tachometer. Can someone explain>how to use macros?There is a really neat function for the forums called "Search..." Use the "Advanced Search," type in a keyword or two, such as "Macro" (w/o the quotes), and you will find every message ever written in this forum on the subject... ;)Possibly the clearest example of XML Macro usage was posted several weeks ago by Tom (taquillo):(A:VELOCITY WORLD X, m/s) (A:VELOCITY WORLD Z, m/s) atg2 rnor(A:pLANE HEADING DEGREES TRUE, radians) s0(L:Cage switch,bool)if{ 0 }els{ @Macro1 l0 - abs 0.5 Wherever you see "@Macro1" used, simply substitute whatever is contained in the Macro1 code! ;)Now it truly makes NO sense to bother with creating a @Macro unless you are planning to use the same calculation more than once or twice in any given gauge project!Notice that in Tom's example he's used the @Macro1 five times!!! thus making the code much easier to write, read and understand... :-beerchug Now, parsing the code above, the first thing Tom's done is store the value of (A:pLANE HEADING DEGREES TRUE, radians) in register s0 (s0 is a temporary memory location used only during this calculation.This allows Tom to further simplify the if/else code because anytime he needs the value of (A:pLANE HEADING DEGREES TRUE, radians), all he needs to do is write l0 (lowercase L for "load" register 0). Note that Tom's used the l0 register five times in the if/else clause as well.Had all of this been written out without the use of the register and the @Macro, the result would have been a very long and messy bit of code!!!!!(L:Cage switch,bool)if{ 0 }els{ (A:VELOCITY WORLD X, m/s) (A:VELOCITY WORLD Z, m/s) atg2 rnor (A:pLANE HEADING DEGREES TRUE, radians) - abs 0.5 Which do you suppose is the easier to write/read/understand and most importantly, maintain? *:-*

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Author

I'm actually a big fan of the search feature, somehow I missed this in all the searches I've done over the last couple of days in various forums. I'm still working at putting rolling numbers in my RPM gauge to show elapsed time using the (A:General eng elapsed time:1,seconds) variable, and this macro would be great for all the different digits I need to shift...I understand that the part is at the top of the code, but how to call it is still unclear. Here's the macro...@1 sp0@3 0 > if{ l0 10 @3 pow * sp0 }l0 int 10 @2 pow % 10 @2 1 - 0 max pow / int And the calling:@ExtDigit((ALGVar),nDigit,nDecimals)Where:(ALGVar) is the A,L or G var from where to extract the digitnDigit is the position of the digit to extract, starting from the right (honor to RPN! )nDecimals is the number of decimals to be included in the calcs.Here's my gauge...right now I can see a number in the window when I look at the gauge in FSPS, but I don't in the sim. @1 sp0 @3 0 > if{ l0 10 @3 pow * sp0 } l0 int 10 @2 pow % 10 @2 1 - 0 max pow / int @ExtDigit((A:GENERAL ENG ELAPSED TIME:1,seconds),1,0) %((A:GENERAL ENG ELAPSED TIME:1,seconds) 3600 / d 1% 60 * r flr )%!04.0f!:%!02.0f!(A:General eng1 rpm,RPM)Sorry the indents don't show...Robert

Best Regards,
Robert Kerr

3D Modeler & Texture Artist
 

  • Moderator

Try this in the statement (remove the other one after the tag: %((@ExtDigit((A:GENERAL ENG ELAPSED TIME:1,seconds),1,0)) 3600 / d 1% 60 * r flr )%!04.0f!:%!02.0f!

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Hi Robert,Some hints:> @ExtDigit((A:GENERAL>ENG ELAPSED TIME:1,seconds),1,0)/Value>Make it Maximum="9", as you're actually extracting one digit :-)And check this against the bmp layout you're using, related to the tag, with between 0 and 9.> %((A:GENERAL ENG ELAPSED TIME:1,seconds) 3600>/ d 1% 60 * r flr )%!04.0f!:%!02.0f!Replace this with %((A:GENERAL ENG ELAPSED TIME:1,hours))%!04d!:%((A:GENERAL ENG ELAPSED TIME:1,hours) 60 %)%!02d!%if you want the result in hhhh:mm format.Regards,Tom

  • Author

Thanks guys! After lots of trial & error last night I have an elapsed time indication using rolling digits. Well, digit at least. The original macro returned an integer value-no scrolling effect. I removed the 'int' entries that were in the bottom line of code, and that got the 100ths position to 'roll'(getting it to roll accurately was a battle).Right now I'm using the original macro for all the other values. When the hundredths get to 0 the tenths position increments without scrolling. Otherwise it slowly 'rolls' all the time. I don't know how to make it wait and scroll only when the value changes.Anyway, it looks good, and even though only the 100ths digit rolls the effect is good.Note: The string was a temporary display to compare the rolling digits to (accuracy check and alignment). It's not used in the final version.Robert

Best Regards,
Robert Kerr

3D Modeler & Texture Artist
 

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.