• 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 Reading external data? [SOLVED]

Messages
67
Country
unitedstates
Is there a way with FSX's XML schema to read a small amount of data from a text file? I've added some v-speeds to the airspeed tape on a PFD, but that makes the gauge specific to a single plane. I'd really like to save two or three speeds to a text file, and have the gauge read the data when it first loads. That way, the gauge itself could live in the GAUGE folder, and only the small data file would have to go into each plane's panel folder.

Or, is there a way to add my own custom data to the aircraft.cfg file? I know that "cruise_speed" is in the [Reference Speeds] section, and that A:Estimated Cruise Speed should load that datum. Can I load my own variable from an aircraft.cfg entry?
 
Is there a way with FSX's XML schema to read a small amount of data from a text file? I've added some v-speeds to the airspeed tape on a PFD, but that makes the gauge specific to a single plane. I'd really like to save two or three speeds to a text file, and have the gauge read the data when it first loads. That way, the gauge itself could live in the GAUGE folder, and only the small data file would have to go into each plane's panel folder.

Or, is there a way to add my own custom data to the aircraft.cfg file? I know that "cruise_speed" is in the [Reference Speeds] section, and that A:Estimated Cruise Speed should load that datum. Can I load my own variable from an aircraft.cfg entry?

To read from (or write to) an external text or .csv file from an XML gauge, use Robbie McElrath's LOGGER. You can get LOGGER here (the BlackBox website), or bundled in XMLTools

However, let me see if I understand your intentions. You plan to load an aircraft with an XML gauge that includes LOGGER instructions, then have that edit, "on-the-fly", the aircraft's aircraft.cfg file?

Bob
 
Last edited:
My intention is be to have several V-speeds stored in a text file, or in the aircraft.cfg. I want my gauge to read the values for those V-speeds, to place the markers in the proper locations on the airspeed tape. So, one aircraft would have a Vy of 157 knots, while another would be 101 knots. The same PFD gauge could be used for both planes, with the Vy bug shown appropriately.

I only need to read the "external" data once, at start-up, and it won't change.

I'll give LOGGER a look. Thanks!
 
Yep, LOGGER can be used to read a .txt file that contains v-speeds. As you indicate, those values can be stored as L:Vars and used to place speed markers on the airspeed tape. Also, as you suggest, that can be accomplished in an init sequence as the gauge loads. It would be much simpler to have the reference speeds in a small text file than figuring out how to read them from an aircraft.cfg file. The latter is possible, but a small .txt file is the way to go.

Getting the file path right might be the tricky part. I need to think about that ...

Bob
 
It looks like LOGGER will do exactly what I want. If only I could get it to work!

So far, I've only managed to disable the gauge entirely, or get it to seem to work but have the LOGGER variables always be zero.

Here's my code:

Code:
  <Element>
  (L:LoadInitialValues, bool) 0 ==
  if{
   'C:\AFSX\Values.txt' (>C:LOGGER:openRead)
   (C:LOGGER:number) (>L:Vy, number)
   (C:LOGGER:number) (>L:Vx, knots)
   (C:LOGGER:number) (>L:Vr, knots)
   (C:LOGGER:number) (>L:Vso, knots)
   1 (>C:LOGGER:closeRead)
   1 (>L:LoadInitialValues, bool)
  }
  </Element>

I originally tried to put this inside an <Update> tag as suggested by the documentation, but I must not know the syntax for <Update> in the FSX schema, because that's what disables the entire gauge.

Shouldn't it be:
Code:
<Update id="Update">
  <Frequency>4</Frequency>
  ... logger stuff here ...
</Update>

This syntax makes the entire gauge disappear! If I comment it out, the gauge seems to work, but the LOGGER variable shows as zero using BlackBox.

I have checked multiple times that C:\AFSX\Values.txt exists and is valid. It's just a text file with 10 numbers in it, each on their own line.
 
XMLTables in XMLTools can be used to read from a table in a gauge.

If you create a gauge containing nothing but an <Update> section with the v-speeds table, you basically have what you need.


- Edit:

Update in FSX syntax is:
Code:
<Update>
<Script>
...
</Script>
</Update>

I think any frequency information goes between "Update" and "Script".

A valid update equivalent in FS9 syntax would be
Code:
<Element>
<Select>
<Value>
...
</Value>
</Select>
</Element>
 
XMLTables in XMLTools can be used to read from a table in a gauge.
For Lieuallen's use, I would argue that a straight LOGGER read is the more appropriate approach.

@Lieuallen - the init sequence within <Update> should work. I don't understand why you need Frequency 4. Try the init sequence without changing frequency, such as:
Code:
<Update>
  (L:LoadInitialValues, bool) 0 ==
    if{
        'C:\AFSX\Values.txt' (>C:LOGGER:openRead)
        (C:LOGGER:number) (>L:Vy, number)
        (C:LOGGER:number) (>L:Vx, knots)
        (C:LOGGER:number) (>L:Vr, knots)
        (C:LOGGER:number) (>L:Vso, knots)
        1 (>C:LOGGER:closeRead)
        1 (>L:LoadInitialValues, bool)
      }
</Update>

And place the <Update> section at the top, or first part of, of your gauge script.
I have checked multiple times that C:\AFSX\Values.txt exists and is valid. It's just a text file with 10 numbers in it, each on their own line.

But, your LOGGER section reads only the first four lines ...

Bob

Syntax to change Update frequency: <Update Frequency="4"/>. I never tried your way before.

Hmmm, it just now registered, your "FSX schema" ... all of my examples in the LOGGER documentation are written in FS9 schema syntax. I can't offer much advice on FSX syntax but I marvel at anyone willing to take on FSX schema. Bjoern (Heretic) is one of them. Including you, I think there are now two.

One reason to crash could be a mix of FS9 and FSX syntax in the same gauge...
 
Last edited:
The PFD only uses the first 4 of the 10 values I have in the Values.txt file, so that's by design.

I'm not happy that it's the FSX schema, but I'm modifying the default LearJet PFD, so that's what I'm stuck with!

Apparently I had some leftover karma, because I think I've finally got it working. The trick was to include the <Script> tags as Heretic suggested, and make sure I had the <Update> section at the top of the code, but below the <SimGauge.Gauge> tag.

Further updates as warrented...!
 
My suggestion would be a single tiny gauge in the respective panel folder of any aircraft:

Code:
<Gauge Name="V speeds">
<Update>
  (G:Var1,bool) !
   if{
      90 (>L:V_Speed_1,number)
      100 (>L:V_Speed_2,number)
      110 (>L:V_Speed_3,number)
      1 (>G:Var1,bool)
   }
</Update>
</Gauge>

That's all.

- You don't need to install XMLTools or anything else. (Although I highly recommend XMLTools...)
- You can use your v-speeds in any of your aircrafts' gauges (your main pfd gauge can still remain in the FSX gauges folder)
- placing a txt file or this tiny gauge in an aircraft folder is the same effort
- Aaaand you don't need to bother about the txt file pathes, which would vary for every aircraft

- drawback: you have to add a line to the panel.cfg, but I don't think that's a problem.
 
Another option is Doug Dawson's config gauge, which will save the value of specified L: variables when you unload the plane (panel), and reload those values when you reload the plane (panel). By using separate cfg files you can make these aircraft specific.
 
@SierraB -- that's a FANTASTIC solution. I'm hoping that when these gauges are done, others will want to use them as well. I've put version 1.0 on FlightSim.com, but that is so yesterday! :rolleyes:

So, I'm slightly concerned that this LOGGER approach will cause potential problems, because the end user will have to install LOGGER to use my gauges. Your solution completely removes that worry! Adding a line in panel.cfg is not a problem, because that would be done by me and not the end user.

I'm off to change my gauges!
 
XMLTools should become as much of a standard as FSUIPC. It's just too damn useful. And I haven't heard a complaint so far.

XMLTables is the way to go if you need to convert entire v speed charts into gauge code. Otherwise, you'll waste quite a bit of space with conditional statements.
 
Back
Top