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

FillColor: String expression syntax question

Messages
1,564
Country
thailand
fs9 XML schema:

I'm trying to write a FillColor string expression equivalent to FillColor="0x123ABC" but using concatenated L:Vars or XMLVars within the color string. Something analogous to:
Code:
FillColor=" '0x' (L:Char1, enum) chr scat
(L:Char2, enum) chr scat
(L:Char3, enum) chr scat
(L:Char4, enum) chr scat
(L:Char5, enum) chr scat
(L:Char6, enum) chr scat"

The script above doesn't work, of course, but I can't figure out the proper syntax to make it work.

I'd like to solve this within the FillColor string expression ... to learn the proper syntax to make concatenation work within the color string.

Thanks for any help.

Bob
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
Bob,

You could try using a script syntax:

FillColor="%( '0x' (L:Char1, enum) chr scat (L:Char2, enum) chr scat (L:Char3, enum) chr scat (L:Char4, enum) chr scat (L:Char5, enum) chr scat (L:Char6, enum) chr scat )"


Tom
 
Messages
440
Country
us-wisconsin
Tom replied just before I..

What he said is true but for a RGB representation as FS uses BGR, it works -

Code:
FillColor="%( '0x' (L:Char5, enum) chr scat (L:Char6, enum) chr scat (L:Char3, enum) chr scat (L:Char4, enum) chr scat (L:Char1, enum) chr scat (L:Char2, enum) chr scat )"

Been putzing with this and built a test gauge -

test.jpg


Code:
<Gauge Name="TEST" Version="1.0">

<Size X="200" Y="60" />
<!-- NOTE COLOR IS NOT RGB! BUT RATHER BGR! -->
<!-- In the evaluation below the color is adjusted to BGR -->
<Macro Name="Color_Eval">%('0x' (L:Char5, enum) chr scat 
        (L:Char6, enum) chr scat
        (L:Char3, enum) chr scat
        (L:Char4, enum) chr scat
        (L:Char1, enum) chr scat
        (L:Char2, enum) chr scat)</Macro>

<Update>
    <!-- Numbers are via CHARMAP in HEX coverted to DECIMAL -->
    <!-- In RGB!!! DECIMAL represented HEX-->
    <!-- Digits "0" thru "9" = 48 thru 57, digits "A" thru "F" = 65 thru 70 --> 
    <!-- Initialize to get in range -->
(G:Var1) 0 == if{    
    49 (>L:Char1, enum)
    50 (>L:Char2, enum)
    51 (>L:Char3, enum)
    65 (>L:Char4, enum)
    66 (>L:Char5, enum)
    67 (>L:Char6, enum) 
    1 (>G:Var1) }   
</Update>


<Element Name="TEST IN STRING">
<Position X="0" Y="0"/>
<!-- The background color expresion below also works with the font color -->
    <FormattedText X="100" Y="40" FontSize="8" Font="Arial" Bright="Yes" Fixed="Yes"
    Color="White"
    BackgroundColor="@Color_Eval">
        <String>Color in RGB HEX = %('0x' (L:Char1, enum) chr scat 
        (L:Char2, enum) chr scat
        (L:Char3, enum) chr scat
        (L:Char4, enum) chr scat
        (L:Char5, enum) chr scat
        (L:Char6, enum) chr scat)%!s!%\n
        Color in FS's BGR HEX = %('0x' (L:Char5, enum) chr scat 
        (L:Char6, enum) chr scat
        (L:Char3, enum) chr scat
        (L:Char4, enum) chr scat
        (L:Char1, enum) chr scat
        (L:Char2, enum) chr scat)%!s!%\n
        %Decimal CHAR Equiv RGB =\n
        %((L:Char1, enum))%!d!, %((L:Char2, enum))%!d!, %((L:Char3, enum))%!d!, %((L:Char4, enum))%!d!, %((L:Char5, enum))%!d!, %((L:Char6, enum))%!d!%</String>
    </FormattedText>
</Element>

<!-- NOTE 50%  TRANSPERANCY!!!! -->
<Element Name="TEST IN RECTANGLE">
<Position X="10" Y="45"/>
    <Rectangle Width="40" Height="15" Transparency="0.5" 
    FillColor="@Color_Eval"/>
</Element>

<Element Name="TEST IN CIRCLE 1 USING FILL COLOR">
<Position X="105" Y="0"/>
<Circle Radius="10" LineWidth="2" Color="#ffffff"
FillColor="@Color_Eval"/>   
</Element>


<Element Name="TEST IN CIRCLE 2 REVERSED">
<Position X="130" Y="0"/>
<Circle Radius="10" LineWidth="2" FillColor="#ffffff" 
Color="@Color_Eval"/>
</Element>

<Element Name="TEST IN ELLIPSE">
<Position X="117" Y="30"/>
    <Ellipse Height="10" Width="20" LineWidth="2" FillColor="@Color_Eval" LineColor="White"/>
</Element>

<Element Name="TEST IN POLYLINE">
<Position X="65" Y="50"/>
    <Polyline LineWidth="2" Bright="Yes" Color="@Color_Eval">
            <Point X="0" Y="-5"/>
            <Point X="5" Y="5"/>
            <Point X="-5" Y="5"/>           
            <Pivot X="0" Y="0"/>
    </Polyline>       
        <Rotate>
            <Value>(P:Local time,seconds) flr 60 % 6 * dgrd</Value>             
        </Rotate>
</Element>

<Element Name="TEST IN POLYGON">
<Position X="85" Y="50"/>
    <Polygon LineWidth="2" Bright="Yes" FillColor="@Color_Eval">
            <Point X="0" Y="-5"/>
            <Point X="5" Y="5"/>
            <Point X="-5" Y="5"/>           
            <Pivot X="0" Y="0"/>
    </Polygon>
        <Rotate>
            <Value>(P:Local time,seconds) flr 60 % 6 * 90 - dgrd</Value>             
        </Rotate>
</Element>

<Element Name="TEST IN HORIZONTAL LINE">
<Position X="95" Y="45"/>
    <HorizontalLine LineWidth="2" Width="20" Bright="Yes" Color="@Color_Eval"/>
</Element>

<Element Name="TEST IN VERTICAL LINE">
<Position X="95" Y="50"/>
    <VerticalLine LineWidth="2" Height="10" Bright="Yes" Color="@Color_Eval"/>
</Element>

<Element Name="TEST IN ARC">
<Position X="120" Y="45"/>
    <Arc LineWidth="2" Bright="Yes" Color="@Color_Eval" Radius="7" StartAngle="215" EndAngle="325"/>
</Element>

<Element Name="TEST IN PIE">
<Position X="135" Y="45"/>
    <Pie LineWidth="1" Bright="Yes" Color="Red" FillColor="@Color_Eval" Radius="10" StartAngle="10" EndAngle="175"/>
</Element>


<Element Name="TEST CONTROL DISPLAY 1">
<Position X="160" Y="0"/>
    <FormattedText X="20" Y="60" FontSize="18" VerticalAlign="Center" Font="Arial" Bright="Yes" Fixed="Yes"
    BackgroundColor="White"
    Color="Red">
    <Color Value="Green"/>
    <Color Value="Blue"/>
   
        <String>
        \{tabs=0L,5C,15C}\t%+\t%-%\n%
        \{tabs=0L,5C,15C}\{clr2}\t%+\t%-%\n%
        \{tabs=0L,5C,15C}\{clr3}\t%+\t%-%\n%
        </String>
    </FormattedText>
</Element>

<Element Name="TEST CONTROL DISPLAY 2">
<Position X="180" Y="0"/>
    <FormattedText X="20" Y="60" FontSize="18" VerticalAlign="Center" Font="Arial" Bright="Yes" Fixed="Yes"
    BackgroundColor="White"
    Color="Red">
    <Color Value="Green"/>
    <Color Value="Blue"/>   
        <String>
        \{tabs=0L,5C,15C}\t%+\t%-%\n%
        \{tabs=0L,5C,15C}\{clr2}\t%+\t%-%\n%
        \{tabs=0L,5C,15C}\{clr3}\t%+\t%-%\n%
        </String>
    </FormattedText>
</Element>

<Mouse>
   
    <Macro Name="Up">(L:Char@1, enum) 57 == if{ 65 } els{ (L:Char@1, enum) ++ 70 min } (>L:Char@1, enum)</Macro>
    <Macro Name="Down">(L:Char@1, enum) 65 == if{ 57 } els{ (L:Char@1, enum) -- 48 max } (>L:Char@1, enum)</Macro>
   
        <Area Name="Red 1 Plus" Left="160" Top="0" Width="10" Height="18">
            <Cursor Type="UpArrow"/>
            <Click Repeat="Yes">
            @Up(1)
            </Click>
        </Area>
        <Area Name="Red 1 Minus" Left="170" Top="0" Width="10" Height="18">
            <Cursor Type="DownArrow"/>
            <Click Repeat="Yes">
            @Down(1)
            </Click>
        </Area>       
        <Area Name="Red 2 Plus" Left="180" Top="0" Width="10" Height="18">
            <Cursor Type="UpArrow"/>
            <Click Repeat="Yes">
            @Up(2)
            </Click>
        </Area>
        <Area Name="Red 2 Minus" Left="190" Top="0" Width="10" Height="18">
            <Cursor Type="DownArrow"/>
            <Click Repeat="Yes">
            @Down(2)
            </Click>       
        </Area>       
        <Area Name="Green 1 Plus" Left="160" Top="20" Width="10" Height="18">
            <Cursor Type="UpArrow"/>
            <Click Repeat="Yes">
            @Up(3)
            </Click>
        </Area>
        <Area Name="Green 1 Minus" Left="170" Top="20" Width="10" Height="18">
            <Cursor Type="DownArrow"/>
            <Click Repeat="Yes">
            @Down(3)
            </Click>
        </Area>       
        <Area Name="Green 2 Plus" Left="180" Top="20" Width="10" Height="18">
            <Cursor Type="UpArrow"/>
            <Click Repeat="Yes">
            @Up(4)
            </Click>
        </Area>
        <Area Name="Green 2 Minus" Left="190" Top="20" Width="10" Height="18">
            <Cursor Type="DownArrow"/>
            <Click Repeat="Yes">
            @Down(4)
            </Click>       
        </Area>       
        <Area Name="Blue 1 Plus" Left="160" Top="40" Width="10" Height="18">
            <Cursor Type="UpArrow"/>
            <Click Repeat="Yes">
            @Up(5)
            </Click>
        </Area>
        <Area Name="Blue 1 Minus" Left="170" Top="40" Width="10" Height="18">
            <Cursor Type="DownArrow"/>
            <Click Repeat="Yes">
            @Down(5)
            </Click>
        </Area>       
        <Area Name="Blue 2 Plus" Left="180" Top="40" Width="10" Height="18">
            <Cursor Type="UpArrow"/>
            <Click Repeat="Yes">
            @Up(6)
            </Click>
        </Area>
        <Area Name="Blue 2 Minus" Left="190" Top="40" Width="10" Height="18">
            <Cursor Type="DownArrow"/>
            <Click Repeat="Yes">
            @Down(6)
            </Click>       
        </Area>       
</Mouse>   
</Gauge>
 
Messages
1,564
Country
thailand
ahhhh ... all my attempts started with FillColor="%0x%(concatenation goes here)". Got it now!

Thanks gents!
 
Top