• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FS2004 Mouse misery

Messages
206
Country
unitedkingdom
Hi folks,

The following code contains a bug, but I cannot see what it might be!

The main part of the gauge is working perfectly but the mouse section is not. When I have it 'as written' below then the left click is working but the right click is not. If I swap the order, then the right click works but the left does not. I have verified elsewhere that the code inside each section is working and also I have three other gauges with exactly the same template but there both clicks are working! Please help, have I done something silly here?

Code:
<Mouse>
<Help ID="HELPID_AUTOPILOT_AUTOTHROTTLE"/>
<Tooltip ID="TOOLTIPTEXT_AUTOPILOT_AUTOTHROTTLE"/>
<Area>
<Cursor Type="Hand"/>
<Click Repeat="No" Kind="LeftSingle+RightSingle">
(M:Event) 'LeftSingle'  scmi 0 == if{ 
[COLOR="DarkSlateGray"](L:isg_vnav, enum) 1 == if{ 1 (&gt;L:isg_vnav_clicked, number) (A:Autopilot altitude lock, bool) 1 == (L:gctoga, enum) 0 == &amp;&amp; (L:CLMB,enum) 0 == &amp; (A:Autopilot approach hold, bool) ! &amp; (A:Indicated Altitude, feet) (A:Autopilot altitude lock var, feet) - abs 750 &gt; &amp; (L:Autoflare,bool) ! &amp; (A:Sim on ground, bool) ! &amp; (A:AIRSPEED TRUE,knots) 10 &gt; &amp; (A:RADIO HEIGHT,feet) 1000 &gt; &amp; (A:AUTOPILOT THROTTLE ARM,bool) &amp; if{ 1 (>L:levelchangeactive,bool) (A:PLANE ALTITUDE,feet) (A:AUTOPILOT ALTITUDE LOCK VAR,feet) &gt; if{ -3.5 s13 } els{ (A:PLANE ALTITUDE,feet) (A:AUTOPILOT ALTITUDE LOCK VAR,feet) - abs 2200 &gt; if{ 4.5 s13 } els{ 3.5 s13 } } l13 0 != if{ (L:FPAhold, enum) 0 == if{ 180 pi / s0 l13 l0 / tg s4 l4 (A:AIRSPEED TRUE,knots) * 101.26859 * s5 l5 100 / near 100 * (>K:AP_VS_VAR_SET_ENGLISH) } els{ l13 (>L:FPASet,enum) } } } } els{ (L:FMSspeedoff,bool) if{ 0 (>L:FMSspeedoff,bool) (L:appspeedX,bool) if{ 1 (>L:appspeed,bool) 0 (>L:appspeedX,bool) } } els{ (L:appspeed,bool) if{ 1 (>L:FMSspeedoff,bool) 0 (>L:appspeed,bool) 1 (>L:appspeedX,bool) (L:goaroundspeed,enum) (A:Autopilot airspeed hold var, knots) 5 + &gt; (L:goaroundspeed,enum) 0 != &amp;&amp; if{ (L:goaroundspeed,enum) (>K:AP_SPD_VAR_SET,knots) 0 (>L:goaroundspeed,enum) } } els{ (L:isg_lnav, enum) 1 == (L:gctoga, enum) 0 == &amp;&amp; if{ (L:FMSsetspeed,bool) if{ 0 (>L:FMSsetspeedX,bool) 0 (>L:FMSsetspeed,bool) } els{ 1 (&gt;L:isg_vnav_clicked, number) } } els{ (L:FMSsetspeed,bool) if{ 0 (>L:FMSsetspeedX,bool) 0 (>L:FMSsetspeed,bool) } els{ 1 (>L:FMSsetspeed,bool) } } } }[/COLOR] 
1 (&gt;L:BUTTON_NORM,number) 2 (>L:atswitchtime,enum) 
} 
(M:Event) 'RightSingle'  scmi 0 == if{ 
1 (&gt;L:BUTTON_NORM,number) 2 (>L:atswitchtime,enum) 
[COLOR="DarkSlateGray"](A:RADIO HEIGHT,feet) 50 &gt; (A:GROUND VELOCITY, knots) 50 &lt; (L:gctoga, enum) 1 == || || if{ (L:attmemory,bool) if{ 0 (>L:attmemory,bool) } 0 (>K:AUTO_THROTTLE_ARM) } els{ (A:Autopilot throttle arm,bool) if{ 0 (>K:AUTO_THROTTLE_ARM) } els{ (L:attmemory,bool) if{ 0 (>L:attmemory,bool) } els{ 0 (>K:AUTO_THROTTLE_ARM) } } [/COLOR]
} 
</Click>
</Area>
</Mouse>

Cheers,
Geoff
 
...Please help, have I done something silly here?

I bet you are missing a } to close the first if{ from the 'LeftSingle' code.
This is the reason that part works fine even if you change the button order.

Tom
 
There are 31 of { and only 29 of }.

I have no idea where the problem is though

Simple. Instead of working like this:

Code:
(M:Event) 'LeftSingle'  scmi 0 == 
if{ etc etc }
(M:Event) 'RightSingle'  scmi 0 == 
if{ etc etc }

the code is working like this:

Code:
(M:Event) 'LeftSingle'  scmi 0 == 
if{  etc etc 
    (M:Event) 'RightSingle'  scmi 0 == 
    if{ etc etc }
   }

Obviously the (M:Event) 'RightSingle' scmi 0 == part won't execute ever.

Tom
 
Ah yes, the dreaded '{' quantity does not equal '}' quantity issue.

Been there done that too many times to be funny anymore! :rolleyes:

I've found that a good code editor (I use Notepad ++ (Google it, it's free)) to be invaluable as it lets you know when you've goofed up like that.
 
I bet you are missing a } to close the first if{ from the 'LeftSingle' code.
This is the reason that part works fine even if you change the button order.

Tom

Got it! Thanks very much. I had foolishly assumed that it wouldn't execute at all with an error like that in there... I also have no idea where exactly the problem was, I just rebuilt the sections logically and now it works.

Geoff
 
This type of problem can be mitigated by copius use of the Enter key to create line breaks!

Instead of typing a long expression on a single line, break it up into shorter segments, and use the Tab key to provide some visible structure...

...the following would be a nightmare to debug and fix were it all on a single, one mile long line! :eek:
Code:
        <Code>
          (L:B737_Init,bool) !
          if{
          1 (>L:PowerAvailableNow,bool)
          1 (>L:B737_Init,bool)
          }

          <!-- RESET ALT FLAPS-->
          (L:B737_AltFlaps,enum) 0 !=
          if{
          (L:Reset,enum) (E:local time, seconds) &gt;
          if{ }
          els{ 0 (>L:B737_AltFlaps, enum) 1 (>L:XMLSND5,bool) }
          }

          <!-- RESET HDG HOLD MODE SWITCH-->
          (L:B737_AP_HDG_HoldMode,enum) 0 !=
          if{
          (L:Reset,enum) (E:local time, seconds) &gt;
          if{ }
          els{ 0 (>L:B737_AP_HDG_HoldMode, enum) 1 (>L:XMLSND5,bool) }
          }

          <!-- RESET APU SWITCH -->
          (L:B737_APU_PwrSwitch, enum) 2 ==
          if{
          (L:Reset,enum) (E:local time, seconds) &gt;
          if{ }
          els{ 1 (>L:B737_APU_PwrSwitch, enum) 1 (>L:XMLSND5,bool) }
          }

          <!-- RESET APU BUS1 SWITCH -->
          (L:B737_APU_Bus1, enum) 0 !=
          if{
          (L:Reset,enum) (E:local time, seconds) &gt;
          if{ }
          els{ 0 (>L:B737_APU_Bus1, enum) }
          }

          <!-- RESET APU BUS3 SWITCH -->
          (L:B737_APU_Bus2, enum) 0 !=
          if{
          (L:Reset,enum) (E:local time, seconds) &gt;
          if{ }
          els{ 0 (>L:B737_APU_Bus2, enum) }
          }

          <!-- RESET GRND PWR SWITCH -->
          (L:B737_GRND_Pwr, enum) 0 !=
          if{
          (L:Reset,enum) (E:local time, seconds) &gt;
          if{ }
          els{ 0 (>L:B737_GRND_Pwr, enum) }
          }

          <!-- RESET GEN BUS1 SWITCH -->
          (L:B737_GEN_Bus1, enum) 0 !=
          if{
          (L:Reset,enum) (E:local time, seconds) &gt;
          if{ }
          els{ 0 (>L:B737_GEN_Bus1, enum) }
          }

          <!-- RESET GEN BUS2 SWITCH -->
          (L:B737_GEN_Bus2, enum) 0 !=
          if{
          (L:Reset,enum) (E:local time, seconds) &gt;
          if{ }
          els{ 0 (>L:B737_GEN_Bus2, enum) }
          }

          <!-- MASTER POWER -->
          (A:APU GENERATOR ACTIVE,bool) 1 ==
          (L:Bus1,volts) 0 &gt;
          or
          (L:Bus2,volts) 0 &gt;
          or
          (L:B737_MasterBattery,bool) 1 ==
          or
          if{ 1 (>L:ElecPowerAvail,bool) }

          <!-- CALCULATE GENERATOR OIL TEMPERATURE -->
          (A:GENERAL ENG OIL TEMPERATURE:1,celsius) (>L:B737_Gen1_OilTemp,enum)
          (A:GENERAL ENG OIL TEMPERATURE:2,celsius) (>L:B737_Gen2_OilTemp,enum)

        </Code>
 
Back
Top