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

FSXA Using scmp to compare strings with no MouseEvent -- SOLVED

Messages
67
Country
unitedstates
I had an idea for a very simple gauge. When flying for my VA, I'd like to have a piece of paper taped to the panel showing the flight number. I did a quick design, and it works pretty well.

Now, I'd like to gussy it up a bit. If there is no flight number, I'd like the paper to say something else (right now, I'm using "Be Safe"). If I'm not flying for an airline, I'd like the whole paper (gauge) to go away.

No problem. I'll just examine the ATC AIRLINE and ATC FLIGHT NUMBER strings and use the <Visible> property.

But it's not working. Apparently, I do not understand what scmp returns. I've only seen it used for MouseEvents, but it should be able to compare any two strings, right? The SDK seems to say that it returns -1 if the strings match. It didn't say what is returned if they don't match -- I guessed zero, but perhaps I'm wrong.

At any rate, I'd appreciate it if you'd take a look at this little XML code, and fix my logic! Right now, the gauge displays correctly if there is an airline defined, and does not appear if there is not. So, right or wrong, my first use of scmp is at least working the way I want. But I thought -1 meant the strings match....

The flight number is vexing me. I either get both strings, or neither to show up. Phooey! I've tried all sorts of random combinations, and finally realized I have no idea what I'm doing!

Code:
<Element>
   <Visible>(A:ATC AIRLINE, string) "" scmp -1 == </Visible>
   <Image Name="NotePaper.bmp" Transparency="0.6"/>

   <Element>
     <Position X="24" Y="48" />
  <Text X="400" Y="70" Length="22" Font="Segoe UI" Color="#2495D7" Adjust="Center">
  <String>%((A:ATC AIRLINE,string))%!s!</String>
  </Text>
   </Element>

   <Element>
     <Position X="26" Y="120" />
     <Rectangle Color ="Black" LineWidth="4" Height="128" Width="400" />
   </Element>

   <Element>
     <Position X="26" Y="120" />
     <Visible>(A:ATC FLIGHT NUMBER,string) "" scmp -1 == </Visible>
      <Text X="400" Y="160" Length="5" Font="Rage Italic" Color="#000000" Adjust="Center" Fixed="No">
      <String>%((A:ATC FLIGHT NUMBER,string))%!s!</String>
      </Text>
   </Element>

   <Element>
     <Position X="26" Y="120" />
     <Visible>(A:ATC FLIGHT NUMBER,string) "" scmp 0 == </Visible>
    <Text X="400" Y="160" Length="7" Font="Rage Italic" Color="#000000" Adjust="Center" Fixed="No">
    <String>Be Safe</String>
      </Text>
     
   </Element>

</Element>

Thanks!
 
The SDK seems to say that it returns -1 if the strings match. It didn't say what is returned if they don't match -- I guessed zero, but perhaps I'm wrong.

I believe the way it works is that scmp returns zero if the strings match, and not zero if the strings do not match. scmp is case sensitive, scmi is not case sensitive.

Additionally, I believe that an empty string should be scripted as two single quotes, not two double quotes.
 
Thanks. But on my system (running FSX Accel.) , all I can tell for sure right now is:

Using single quotes doesn't work at all
If the strings don't match, scmp returns -1 (using 1 instead doesn't work; it has to be -1)
I don't know what is returned if the strings do match, because I don't know what a "blank" flight number returns (is it null, or is it zero?)
 
Thanks. But on my system (running FSX Accel.) , all I can tell for sure right now is:

Using single quotes doesn't work at all
If the strings don't match, scmp returns -1 (using 1 instead doesn't work; it has to be -1)
I don't know what is returned if the strings do match, because I don't know what a "blank" flight number returns (is it null, or is it zero?)

Using single quotes does work. You must compare (A:ATC FLIGHT NUMBER,string) '' scmp 0 == . Gives 1 (true) if (A:ATC FLIGHT NUMBER,string) is empty -no airline selected.
Notice that '' are two single ' put together.

strcmp and strcmi are both equivalent to C++ string comparing functions.

Possible return ASCII values are:

< 0 the first character that does not match has a lower ASCII value in String1 than in String2
0 the contents of both strings are equal
>0 the first character that does not match has a greater ASCII value in String1 than in String2

For example:

(A:ATC FLIGHT NUMBER,string) is 'Airwave'

comparing (A:ATC FLIGHT NUMBER,string) 'Air' scmi == returns 119, the ASCII value of "w"

Tom
 
I use this bit of code to check the title= line in a [fltsim] entry for a specific string:
Code:
(A:TITLE, string) 'PAX' sstr 0 &gt;

Will return "1" if the repaint title contains "PAX" and "0" if it doesn't.
 
By crackies, that seems to have done the trick! Using your explanation I was able to use the "not" operator (!) to simply see if the string was not null. And now the single quotes work as well!

I'll post this little gauge on FlightSim.com in a bit....

Thanks for your help!
 
Back
Top