• 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.

Newbie with a code problem

Messages
231
Country
us-alabama
Hi guys!

I am working thru the xml gauge tutorials at http://www.fs2x.com/Tutorials.htm
My problem lies in Chapter 2. Interaction Sections/1.7 Left and Right Clicks of the first tutorial. I am writing

my code for use in FS2004.

My code:

Code:
<Gauge Name="f4u1 mouse" Version="1.0">
   <Image Name="mouse1.bmp"/>
   <Update Frequency="2"/>
   <Mouse>
         <Area Left="0" Top="0" Width="50" Height="20">      
         <Area Right="20">
            <Tooltip>Altimeter (%((A:indicated altitude,feet))%!d! feet)</Tooltip>
           <Cursor Type="Hand"/>
           <Click Kind="LeftSingle+RightSingle" Repeat="Yes">
            (M:Event) 'LeftSingle' (&gt;K:ATTITUDE_BARS_POSITION_UP)
            (M:Event) 'RightSingle' (&gt;K:ZOOM_IN)
         </Click>
         </Area>
         <Area Left="30" Top="0" Width="20" Height="20">
            <Tooltip>Radio Height (%((A:Radio height, feet))%!3d!)</Tooltip>
           <Cursor Type="Hand"/>
           <Click Event="ATTITUDE_CAGE_BUTTON" Repeat="Yes"/>
         </Area>
        </Area>
  </Mouse> 
</Gauge>

Produces both mouse left and right mouse events at the same time when I click either left or right mouse

button. Did I misunderstand the point of the tutorial? I thought this code would produce the

ATTITUDE_BARS_POSITION_UP event on left mouse clicks and the ZOOM_IN event on right mouse clicks.

So did I read the tutorial wrong or did I just screw up my code? If I screwed up my code can someone review

it and tell me where I messed up?

Carl
 
This scmp 0 == instruction is probably missing.

Code:
     (M:Event) 'LeftSingle' scmp 0 == 
           if{ (&gt;K:ATTITUDE_BARS_POSITION_UP) }

     (M:Event) 'RightSingle' scmp 0 == 
           if{ (&gt;K:ZOOM_IN) }

Ted.
 
Thank you Ted!

I figured it was a screw up in my code. What does the scmp 0 == instruction tell the code to do? I am still learning the finer points of xml code. I will try your code and post results here.
Thanks again!
Carl
 
(M:Event) returns a string
'LeftSingle' is a string
scmp compares these two strings
== 0 for some strange reason if the two strings are the same the result is 0 (not 1 or -1 or true as one would expect) so the == 0 will be true if (M:Event) and 'LeftSingle' are the same.

scmp is case sensitive

scmi is not case sensitive.

Use scmp if you can as this will be quicker (in theory).


Here is a list of the possible values you will get from (M:Event):

LeftAll

RightAll

MiddleAll

RightSingle

MiddleSingle

LeftSingle

RightDouble

MiddleDouble

LeftDouble

RightDrag

MiddleDrag

LeftDrag

Move

RightRelease

MiddleRelease

LeftRelease

WheelUp

WheelDown

Leave
 
Anthony31

Thank you for the explanation and the list. The tutorial moves into Drag functions next so the list will probably come in handy.

Carl
 
Back
Top