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.

XML if/else logic

Featured Replies

Hi all,If trying to apply this C++ logic to an Xml gauge <click> tag, I'm basically trying to get a switchto rotate through 3 positions (0,1,2)if(eng_switch == 0) eng_switch = 1;else if(eng_switch == 1) eng_switch = 2;else eng_switch = 0;I've tried this....<Click>(L:eng_switch,enum) 0 == if{ 1 (>L:eng_switch,enum) } els{ (L:eng_switch,enum) 1 == if{ 2 (>L:eng_switch,enum) } els{ 0 (>L:eng_switch,enum) }}</Click>But this seems to only toggle the switch between position 0 and 1.Anyone know what I am missing here ?Thanks.Regards.Ernie.

ea_avsim_sig.jpg

Ernie, Truly an honor :-) Here are some examples ( not tested ) but should be OK. Included with up/down, loop/no loop examples. With all have a value of 0-2Go up, stop at 2

<Click>(L:eng_switch,enum) ++ 2 min (>L:eng_switch,enum)</Click>

Go down, stop at 0

<Click>(L:eng_switch,enum) -- 0 max (>L:eng_switch,enum)</Click>

This is an example of increase only with a reset to the minimum, value IE loop. Could be done many other ways.....

<Click>(L:eng_switch,enum) ++ (>L:eng_switch,enum) (L:eng_switch,enum) 3 == if{ 0 (>L:eng_switch,enum) }</Click>

This is an example of decrease only with a reset to the maximum value, IE loop. Could be done many other ways.....

<Click>(L:eng_switch,enum) -- (>L:eng_switch,enum) (L:eng_switch,enum) -1 == if{ 2 (>L:eng_switch,enum) }</Click>

++ in xml equals add 1-- in xml equals subtract 1Just in case.I hope this can help.. Highest Regards,Roman

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

 

  • Moderator

Roman's already given you the "best" solution, but just for the sake of example, formatting and spaces are everything in XML. You needed to add at least one space between the final curly braces: } }Here's how I format XML using indents to make it easier to read, and eliminating the unnecessary else if's:

<Click>  (L:eng_switch,enum) 0 == 	if{ 		1 (>L:eng_switch,enum) 	  }   (L:eng_switch,enum) 1 ==	if{		2 (>L:eng_switch,enum) 	  }  (L:eng_switch,enum) 2 ==	if{	   0 (>L:eng_switch,enum) 	  }</Click>

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Author

Roman , Bill,Thanks very much, that's just what I needed.Thanks Bill was well regarding the formatting tips.Regards.Ernie.

ea_avsim_sig.jpg
  • Moderator
Thanks Bill was well regarding the formatting tips.
No problem!Just to complete the set, here's yet another method using Left/Right mouse clicks... :(
<Click>	 (M:Event) 'RightSingle' scmp 0 ==  		  if{ (L:eng_switch,enum) -- 0 max (>L:eng_switch,enum) }	 (M:Event) 'LeftSingle' scmp 0 ==  		  if{ (L:eng_switch,enum) ++ 2 min (>L:eng_switch,enum) }</Click>

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Ernie & BillJust adding a touch to Bill's response - To have a left/right click is it necessary to "declare before querying" multiple click styles in a <click> attribute? Maybe/maybe not, never tried. I guess tis all dependant on system ( not FS 9? maybe 10? ) and .net versions. Just adding the "known" way to do it in FS9. The very first line is the only line modified from Bill's post.Roman

<Click Kind="LeftSingle+RightSingle">     (M:Event) 'RightSingle' scmp 0 ==            if{ (L:eng_switch,enum) -- 0 max (>L:eng_switch,enum) }     (M:Event) 'LeftSingle' scmp 0 ==            if{ (L:eng_switch,enum) ++ 2 min (>L:eng_switch,enum) }</Click>

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

 

  • Moderator

Yes, Roman. That is a requirement for both FS9 and FSX.Of course, one could also simply declare this to cover every contingency:

<Click Kind="LeftAll+MiddleAll+RightAll">

I don't really recommend this however, since occasionally some unexpected consequences may occur... :(

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

RGR that Bill. "Drag" for one... It worked well in FS02 on XP & FS04 XP pre update anything. Donot know what caused it, FS update, XP update.??????? Now I have a problem where the mouse activate on "drag" will not release properly & let go without going to a "hotspot" and activating that particular one. The code is trying to pull X/Y values during the OP. Yes, tested it too on a super simple "drag" command without the X/Y pull, still the same weird stuff, maybe a total focus for VC? with a loss for 2d? Total loss on this one... It was/is an 02 code. ( no known differences for 04 )But yes,,<Click Kind="LeftAll+MiddleAll+RightAll">NOT GOOD ! <- tried, tested & delivered.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.