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.

Dynamically changing a Macro

Featured Replies

Hi,I’m trying to ‘dynamically’ change a macro result based on an LVar value, and running into trouble.The case is out of the SDK:

<Macro Name="ENGINE_NUMBER">1</Macro><Value Minimum="2" Maximum="30">(A:Eng fuel flow GPH:@ENGINE_NUMBER,gallons per hour)</Value>

But, instead of a static number, “1”, in the ENGINE_NUMBER macro, I was hoping to substitute an LVar such as:

<Macro Name="ENGINE_NUMBER">(L:EngineNumber, enum)</Macro>

with the LVar defined by 1 (>L:EngineNumber, enum).(A:Eng fuel flow GPH:@ENGINE_NUMBER,gallons per hour) always returns 0 (yeah, the engine is running) instead of the correct gph when the LVar is substituted for the static value in the macro, yet, if I assign the result of the macro to another LVar:

@ENGINE_NUMBER (>L:EngNumFromMacro, enum)

I get back the correct value for L:EngineNumber, 1.I do not know if I have a syntax error or if what I am attempting is not allowed.Any suggestions?Thanks in advance,Bob

  • Moderator

It might be helpful to remember that @Macros are static. They are nothing more nor less than simple ASCII shortcuts. They are literal text and are never evaluated.

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

This can work, but... Is it worth it? I assume what you're trying to do is to have an engine selection switch to control the output on a multiple set of gauges --correct?

<Macro Name="EngineFF">(A:Eng fuel flow GPH:@1, gallons per hour) 2 max 30 min (>L:MySelectedFuelFLow,number)</Macro><Macro Name="EngineN1">(A:TURB ENG N1:@1, percent) 2 max 30 min (>L:MySelectedN1,number)</Macro><Update>@EngineFF(4) @EngineFF(3) @EngineFF(2) @EngineFF(1) 4 (L:EngineNumber, number) case@EngineN1(4) @EngineN1(3) @EngineN1(2) @EngineN1(1) 4 (L:EngineNumber, number) case</Update><Mouse><Click>1 4 3 2 4 (L:EngineNumber, number) case (>L:EngineNumber, number)</Click></Mouse><!-- (L:EngineNumber, number) is the engine selection, (L:MySelectedFuelFLow, number) is your selected fuel flow output, just for an example i included N1, (L:MySelectedN1,number) -->

Hope this helps,RomanEDIT - This may even be better...

<Macro Name="EngineSel">(A:Eng fuel flow GPH:@1, gallons per hour) 2 max 30 min (>L:MySelectedFuelFLow,number) (A:TURB ENG N1:@1, percent) 2 max 30 min (>L:MySelectedN1,number)</Macro><Update>@EngineSel(4) @EngineSel(3) @EngineSel(2) @EngineSel(1) 4 (L:EngineNumber, number) case</Update><Mouse><Click>1 4 3 2 4 (L:EngineNumber, number) case (>L:EngineNumber, number)</Click></Mouse><!-- (L:EngineNumber, number) is the engine selection, (L:MySelectedFuelFLow, number) is your selected fuel flow output, just for an example i included N1, (L:MySelectedN1,number) -->

Edited by spokes2112

20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

  • Author

Gentlemen, Thanks for the quick response, as usual. You guys are always so helpful.Bill - thanks for the re-direct on macros. You explained why my approach was not working.Roman, intriguing alternate approach, but I have not yet gotten it to work... In the end, I'm just trying to use some code to change the Engine selection of the AVar from Engine 1 to Engine 2 without hand editing the ENGINE_NUMBER macro.Khop khun makk khrab.Bob

  • Commercial Member

I think the problem was that you were constructing -concatenating- a variable name. Basically FSX saw this...

(A:Eng fuel flow GPH:(L:EngineNumber,enum),gallons per hour)

Which won’t work, as far as I know.I think a standard condition statement like if or case would work better.try...

<!-- 0=eng1 1=eng2 --><Value Minimum="2" Maximum="30">	(L:EngineNumber,enum)		if{ (A:Eng fuel flow GPH:2,gallons per hour) }		els{ (A:Eng fuel flow GPH:1,gallons per hour) }</Value>

or...

<!-- 0=eng1 1=eng2 2=eng3 3=eng4 --><Value Minimum="2" Maximum="30">	(A:Eng fuel flow GPH:4,gallons per hour)	(A:Eng fuel flow GPH:3,gallons per hour)	(A:Eng fuel flow GPH:2,gallons per hour)	(A:Eng fuel flow GPH:1,gallons per hour)	4	(L:EngineNumber,enum)	case</Value>

If you like, put this in a macro...so you can re-use the snipet in several places...

<Macro Name="ENGINE_NUMBER">	(L:EngineNumber,enum)		if{ (A:Eng fuel flow GPH:2,gallons per hour) }		els{ (A:Eng fuel flow GPH:1,gallons per hour) }</Macro>...<Value Minimum="2" Maximum="30">@ENGINE_NUMBER</Value>

Bob, 1st off, my apologies for steering you the wrong way. Finally got the chance to to test out my above theory/post.. It will not work for A: vars at all. I know for a fact it "does" work for L: Vars from which I got the theory. Plus there were other problems, in the <Click> section to be exact. ( Wouldn't initialize properly on aircraft load ) Some snippets from code that works perfectly using L:Vars as an example ---

<Macro Name="DONE">@SOUND(5) @ACTIVATE @TIMER</Macro>   <!--- THIS LINE SHOWS THE L:VAR  SELECTION BEING SENT --><Macro Name="SOUND">1 (>L:Sd@1, Number)</Macro> 		<!--- THIS LINE SHOWS THE L:VAR EXAMPLE BEING WRITTEN Ex.   (>L:Sd5, Number),  (>L:Sd32, Number),   (>L:Sd33, Number),  (>L:Sd34, Number) --><Update>(L:PlaySnd, Bool) 1 == @TYPE 0 > and if{@KYBD 48 == if{ @SOUND(32) }  <!--- THESE LINES SHOW THE L:VAR  SELECTION BEING SENT -->@KYBD 49 == if{ @SOUND(33) } @KYBD 50 == if{ @SOUND(34) }}</Update>

Here's the tested code for your original question, about the only advantage to using this is to "get it out of the way" of your other code in the same gauge or to use it as a separate logical gauge. I tested it using a 4 engine recip aircraft.

<!-- L:RPM = RPM, L:FF = Fuel Flow, L:MP = Manifold pressure,  L:EngineNumber = the engine selected minus 1 --><Macro Name="EngineSel">(A:GENERAL ENG4 RPM, rpm) (A:GENERAL ENG3 RPM, rpm) (A:GENERAL ENG2 RPM, rpm) (A:GENERAL ENG1 RPM, rpm) 4 @1 case (>L:RPM,number) (A:RECIP ENG4 FUEL FLOW, gallons per hour) (A:RECIP ENG3 FUEL FLOW, gallons per hour) (A:RECIP ENG2 FUEL FLOW, gallons per hour) (A:RECIP ENG1 FUEL FLOW, gallons per hour) 4 @1 case (>L:FF,number)(A:ENG4 MANIFOLD PRESSURE, inHg) (A:ENG3 MANIFOLD PRESSURE, inHg) (A:ENG2 MANIFOLD PRESSURE, inHg) (A:ENG1 MANIFOLD PRESSURE, inHg) ) 4 @1 case (>L:MP,number) </Macro><Update>@EngineSel((L:EngineNumber, number))</Update><Click>0 3 2 1 4 (L:EngineNumber, number) case (>L:EngineNumber, number)</Click><!-- Testing output string <String>%RPM %((L:RPM,number))%!d!%  FF %((L:FF,number))%!d!%  MP %((L:MP,number))%!d!%</String>-->

When Iread that it didn't work for you - just had to give it a try since it was only an "&amp;@(&#036;*"umed theory LOL!Hope this may help.Roman

20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

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.