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

FSX XML Button

Messages
97
Country
sweden
Hello,

I need some help with a button. I have a button that when pressed, text on a display will showup. When I press the same button a second time a new text will showup, when I press the same button a third time, a new text will show and when I press the 4th time the first text will show again.

I know how to make a - + button, for example like the code below:

Code:
<MouseArea id="Regulator DEC">
                    <FloatPosition>0.000,0.000</FloatPosition>
                    <Size>100,110</Size>
                    <CursorType>DownArrow</CursorType>
                    <MouseClick id="MouseClick">
                        <Script>(L:Regulator,number) -- s0 0 &lt; if{ 0 } els{ l0 } (&gt;L:Regulator,number)</Script>
                        <ClickType>LeftSingle</ClickType>
                    </MouseClick>
                </MouseArea>
                <MouseArea id="Regulator INC">
                    <FloatPosition>49.000,0.000</FloatPosition>
                    <Size>99,110</Size>
                    <CursorType>UpArrow</CursorType>
                    <MouseClick id="MouseClick">
                        <Script>(L:Regulator,number) ++ s0 2 &gt; if{ 2 } els{ l0 } (&gt;L:Regulator,number)</Script>
                        <ClickType>LeftSingle</ClickType>
                    </MouseClick>
                </MouseArea>

But how do I create a, "step" button that will return to the start again after I have stepped through the selections?

Regards,
John
 
This will add 1 to the regulator each time you click the button. When it is greater than 3 it will reset the regulator to 0. The values this will return are 0,1,2 and 3

Code:
(L:Regulator,number) ++ (&gt;L:Regulator,number)
(L:Regulator,number) 3 &gt; if{ 0 (&gt;L:Regulator,number) }
 
This will do the same thing as Anthony31's example:
Code:
(L:Regulator,number) ++ 3 % (>L:Regulator,number)
 
Hello,

I need some help with a button. I have a button that when pressed, text on a display will showup. When I press the same button a second time a new text will showup, when I press the same button a third time, a new text will show and when I press the 4th time the first text will show again.

I understand that your different texts should display when a control variable goes from 1 to 3 and back to 1, starting from a no text situation which would be 0 for the control var. Is this correct?

If so, a simple formula could be something like:

Code:
(L:ControlVar,number) ++ 4 % d 0 == + (>L:ControlVar,number)


Tom
 
:) Thanks,
Many ways of achieving the same thing. I am amazed by the many ways it is possible to write XML code and in some cases the huge amount of code one have to write in order for something to work. I have found a new respect for the people that create these wonderful FSX aircraft and sceneries.

Regards,
John
 
I use the following to toggle either forwards or backwards through pages in several instruments.

2 switch buttons:
Code:
 <!--5 Page toggle switches  2 buttons each Left click-->
  <!--Forward continous loop through pages-->
   <Area Left="425" Top="4" Width="55" Height="50">
  <Cursor Type="UpArrow"/>
    <Click>
      (L:APdisplay mode,enum) ++ 5 % (&gt;L:APdisplay mode,enum)
    </Click>
  </Area>
   <!--Backwards to original page-->
  <Area Left="400" Top="4" Width="24" Height="50">
  <Cursor Type="DownArrow"/>
    <Click>
      (L:APdisplay mode,enum) -- 0 max (&gt;L:APdisplay mode,enum)
    </Click>
  </Area>

1 switch button:
Code:
 <!--5 Page toggle switche  1 button Left and Right clicks-->
    <Area Left="425" Top="4" Width="55" Height="50">
      <Click Kind="LeftSingle+RightSingle" Repeat="Yes">
              (M:Event) 'LeftSingle' scmp 0 ==  if{ (L:APdisplay mode,enum) ++ 5 % (&gt;L:APdisplay mode,enum) }
              (M:Event) 'RightSingle' scmp 0 == if{ (L:APdisplay mode,enum) -- 0 max (&gt;L:APdisplay mode,enum) }</Click>
      <Tooltip>Page Toggle +/-</Tooltip>              
      <Cursor Type="Hand" />
    </Area>

The forward toggle through pages as follows,
0,1,2,3,4,5,0,1,2,3,4,5, .... continuous repeating loop.

The rearward toggles through pages as follows,
5,4,3,2,1,0 then stops at 0.

What I would like is a continuous repeating loop such as,
5,4,3,2,1,0,5,4,3,2,1,0, .... continuous repeating loop.
This would be a handy feature when the instrument has a large number of pages.

Any ideas on how to achieve a continuous loop for rearwards toggle ?

Cheers
Karol
 
I use the following to toggle either forwards or backwards through pages in several instruments.

2 switch buttons:
Code:
 <!--5 Page toggle switches  2 buttons each Left click-->
  <!--Forward continous loop through pages-->
   <Area Left="425" Top="4" Width="55" Height="50">
  <Cursor Type="UpArrow"/>
    <Click>
      (L:APdisplay mode,enum) ++ 5 % (&gt;L:APdisplay mode,enum)
    </Click>
  </Area>
   <!--Backwards to original page-->
  <Area Left="400" Top="4" Width="24" Height="50">
  <Cursor Type="DownArrow"/>
    <Click>
      (L:APdisplay mode,enum) -- 0 max (&gt;L:APdisplay mode,enum)
    </Click>
  </Area>

1 switch button:
Code:
 <!--5 Page toggle switche  1 button Left and Right clicks-->
    <Area Left="425" Top="4" Width="55" Height="50">
      <Click Kind="LeftSingle+RightSingle" Repeat="Yes">
              (M:Event) 'LeftSingle' scmp 0 ==  if{ (L:APdisplay mode,enum) ++ 5 % (&gt;L:APdisplay mode,enum) }
              (M:Event) 'RightSingle' scmp 0 == if{ (L:APdisplay mode,enum) -- 0 max (&gt;L:APdisplay mode,enum) }</Click>
      <Tooltip>Page Toggle +/-</Tooltip>            
      <Cursor Type="Hand" />
    </Area>

The forward toggle through pages as follows,
0,1,2,3,4,5,0,1,2,3,4,5, .... continuous repeating loop.

The rearward toggles through pages as follows,
5,4,3,2,1,0 then stops at 0.

What I would like is a continuous repeating loop such as,
5,4,3,2,1,0,5,4,3,2,1,0, .... continuous repeating loop.
This would be a handy feature when the instrument has a large number of pages.

Any ideas on how to achieve a continuous loop for rearwards toggle ?

Cheers
Karol

Hello Karol,

I only have the following code for you. I am not sure if this is what you want but if you press the button it will count backwards and then start over again in a continous loop.

Code:
<MouseArea id="DN Button">
                <FloatPosition>197.000,327.000</FloatPosition>
                <Size>45,40</Size>
                <CursorType>Hand</CursorType>
                <MouseClick id="MouseClick">
                    <Script>
                        (M:Event) &apos;LeftSingle&apos;
                        scmp 0 ==
                        if{ 1 (&gt;G:Var8)
                            (A:ELECTRICAL AVIONICS BUS VOLTAGE,volts) 0 &gt;
                            if{
                                (L:Radar Screen, number)
                                --
                                s0
                                2 &lt; if{ 7 } els{ l0 }
                                (&gt;L:Radar Screen, number)
                              }  
                        }
                        (M:Event) &apos;LeftRelease&apos; scmp 0 == if{ 2 (&gt;G:Var8) }
                    </Script>
                    <ClickType>LeftSingle+LeftRelease</ClickType>
                </MouseClick>
                <Tooltip id="Tooltip">
                    <DefaultId></DefaultId>
                </Tooltip>
            </MouseArea>


Code:
<Element id="DN Button">
            <FloatPosition>197.000,327.000</FloatPosition>
            <Select id="Select">
                <Expression id="Expression">
                    <Minimum>0.000</Minimum>
                    <Maximum>1.000</Maximum>
                    <Script>(G:Var8)</Script>
                </Expression>
                <Case id="Case">
                    <ExpressionResult>0.000</ExpressionResult>
                    <Image id="Image" Name="DN.bmp">
                        <Transparent>True</Transparent>
                    </Image>
                </Case>
                <Case id="Case">
                    <ExpressionResult>1.000</ExpressionResult>
                    <Image id="Image" Name="DN.bmp">
                        <Transparent>True</Transparent>
                    </Image>
                </Case>
            </Select>
        </Element>

The (&gt;G:Var8) is the button itself.......the 2 is the min page number and if{ 7 } is the maximum page number.

Just insert:
<Visibility>(L:Radar Screen,number) 2 ==</Visibility>
In the document where you have your pages and this page will automatically showup when you press the button. Next time you press the button page 7
<Visibility>(L:Radar Screen,number) 7 ==</Visibility>
will show.....2, 7, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2........
This makes a continous loop from lowest to highest and back to lowest page number.

Hope this is of any help?

John
 
Last edited:
What I would like is a continuous repeating loop such as,
5,4,3,2,1,0,5,4,3,2,1,0, .... continuous repeating loop.
This would be a handy feature when the instrument has a large number of pages.

Any ideas on how to achieve a continuous loop for rearwards toggle ?

Yes, and its really simple:

(L:APdisplay mode,enum) -- d 0 &lt; 6 * + (>L:APdisplay mode,enum)

The number in blue must be always the upper limit plus one, it's easy to figure out why ;)

Tom
 
Thank you John

Thank you Tom

My applicable MFD instrument has 5 pages ... 0,1,2,3,4,5 .
1 button switch (F) Left and (R) Right click.

I tried this switch,
Forward code from post #4 above.
Rearward code from post #8 above.
RESULTS:- The Rearward cycle worked beautifully ,but, the forward cycle lost Page 1 (enum 0) , it just
did not appear.

Code:
 <!--MFD Display Pages  toggle-->
     <Area Left="400" Top="4" Width="79" Height="50">
      <Click Kind="LeftSingle+RightSingle" Repeat="Yes">
        (M:Event) 'LeftSingle' scmp 0 ==  if{ (L:APdisplay mode,enum) ++ 5 % d 0 == + (&gt;L:APdisplay mode,enum) }
        (M:Event) 'RightSingle' scmp 0 == if{ (L:APdisplay mode,enum) -- d 0 &lt; 6 * + (>L:APdisplay mode,enum) }</Click>
      <Tooltip>Page Toggle +/-</Tooltip>              
      <Cursor Type="Hand" />
    </Area>


********
Then I tried this switch,
NOTE:- The applicable Rearwards value has been reduced from 6 to 5.
RESULTS:- Works perfectly for both Forward and Rearward cycles , tested through a series of
both cycles and still worked as required.

Code:
 <!--MFD Display Pages  toggle-->
     <Area Left="400" Top="4" Width="79" Height="50">
      <Click Kind="LeftSingle+RightSingle" Repeat="Yes">
        (M:Event) 'LeftSingle' scmp 0 ==  if{ (L:APdisplay mode,enum) ++ 5 % (&gt;L:APdisplay mode,enum) }
        (M:Event) 'RightSingle' scmp 0 == if{ (L:APdisplay mode,enum) -- d 0 &lt; 5 * + (>L:APdisplay mode,enum) }</Click>
      <Tooltip>Page Toggle +/-</Tooltip>              
      <Cursor Type="Hand" />
    </Area>

Cheers
Karol
 
Karol,

If your MFD has 5 pages starting from 0, then your upper limit will be 4 : 0-1-2-3-4
I think you got confused about this detail. Remember in both cases, forward and backward, the controlling value must be the upper limit plus one. That's the reason you had to write 5 instead of 6 in your code.

Tom
 
Tom,

You are correct.
Due to my carelessness I was misleading above.

This 0,1,2,3,4,5 . was wrong .

Should have read 0,1,2,3,4 .

Sorry about that , it was 5 pages.

I really appreciate the assistance and guidance that I have received from yourself and
others at this forum on many occasions.

Below is an example for those using the Aces FSX style script.

Cheers
Karol

Code:
            <MouseArea id="MODE_SWITCH">
                <FloatPosition>318.000,364.000</FloatPosition>
                <Size>48,40</Size>
                <CursorType>Hand</CursorType>
                <MouseClick id="MouseClick">
                    <Script>
                    (M:Event) 'LeftSingle' scmp 0 ==  if{ (L:GrndMap_Variant,enum) ++ 6 % (&gt;L:GrndMap_Variant,enum) }
                    (M:Event) 'RightSingle' scmp 0 == if{ (L:GrndMap_Variant,enum) -- d 0 &lt; 6 * + (>L:GrndMap_Variant,enum) }
                    </Script>
                    <ClickType>LeftSingle+RightSingle</ClickType>
                </MouseClick>
                <Tooltip id="Tooltip">
                    <DefaultScript>'+/-'Scan Mode cycle</DefaultScript>
                </Tooltip>
            </MouseArea>
 
Back
Top