- Messages
- 240
- Country

I was trying to reply to a question in the other thread, but it was closed while I was typing it...let's try again here.
That's not how you do it in C++. Not the only way, at least...I would probably use Simconnect ONLY if I had to program an EXTERNAL Simconnect client (an out-of process .EXE which runs together with FSX), because an external client doesn't have any other choice than using the Simconnect client-server model to access simulation variables.
However, a Gauge or a module, which runs in-process with FSX ( a .DLL loaded by FSX ), can access to the simulation variables directly, using the function from Panels.dll, with no Simconnect needed, and a more straightforward way of using it. Your example would look like this in C++
That's NOT the most efficient of doing it, it's just to show you how it would look like and that it CAN be an easy to read one-liner.
In a real program, I would have it wrapped in a C++ class, instead, that would call get_aircraft_var_enum and get_units_enum only once when the sim starts, since their token won't change while FSX is running, so there's no reason why you would call it every time you need to read the variable. But that's the optimization part...
Really, if you don't get into the mindset of REALLY using C++, which means using it properly, with the things that MAKE what C++ is about, namely Object-oriented programming, with classes and templates, you are entirely missing what makes C++ more productive, and are in fact using C.
I believe that THESE kind of tutorials are probably more needed.
Let me just illustrate an example:
Get Engine N1 Parameter:
XML-Use A: Vars and that's it.
C++-Add variable into Simconnect Data Structure, more keystrokes to add to data definition, Finally access the struct to get N1 data.
You can clearly see the steps and number of key strokes is way more.
That's not how you do it in C++. Not the only way, at least...I would probably use Simconnect ONLY if I had to program an EXTERNAL Simconnect client (an out-of process .EXE which runs together with FSX), because an external client doesn't have any other choice than using the Simconnect client-server model to access simulation variables.
However, a Gauge or a module, which runs in-process with FSX ( a .DLL loaded by FSX ), can access to the simulation variables directly, using the function from Panels.dll, with no Simconnect needed, and a more straightforward way of using it. Your example would look like this in C++
Code:
n1 = aircraft_varget( aircraft_varget( get_aircraft_var_enum( "ENG N1 RPM" ), get_units_enum("rpm") , 0 )
That's NOT the most efficient of doing it, it's just to show you how it would look like and that it CAN be an easy to read one-liner.
In a real program, I would have it wrapped in a C++ class, instead, that would call get_aircraft_var_enum and get_units_enum only once when the sim starts, since their token won't change while FSX is running, so there's no reason why you would call it every time you need to read the variable. But that's the optimization part...
Really, if you don't get into the mindset of REALLY using C++, which means using it properly, with the things that MAKE what C++ is about, namely Object-oriented programming, with classes and templates, you are entirely missing what makes C++ more productive, and are in fact using C.
I believe that THESE kind of tutorials are probably more needed.





