• 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 Making Logger Work

Heretic

Resource contributor
Messages
6,830
Country
germany
I have been trying for some time now and I just can't make Robbie McElrath's Logger work.

It is correctly installed (FSX\Logger\LoggerX.dll) and the dll.xml entry points to the correct file.

The code for Logger runs in a gauge in an update section. It's supposed to be triggered by a configuration variable with a fixed value and a cockpit switch (for testing purposes).

Code:
  <Update id="Save/Load State">
  <Frequency>18</Frequency>
  <Script>
  (L:SAVELOAD STATE,bool)
  (L:MP_ENG_HIDE_Ctrls_Switch, Bool)
  and
  if{
  (L:SaveInitialValues, bool) 1 ==
    if{
      'D:\Flight Simulator X\Logger\Metro3_State.txt' scat (>C:LOGGER:openWrite)
     
      (L:VIS_Flight_Yoke, Bool) (>C:LOGGER:number)
       
      1 (>C:LOGGER:closeWrite)   
      0 (>L:SaveInitialValues, bool) 
    } }

Nothing ever happens though, i.e. no file is generated. What am I doing wrong?
 
Last edited:
Tried it with a very simple key-based event without success.

Code:
  <KeyMap id="KeyMap">
  <Trigger id="x">
  <KeyEvent>FLAPS_INCR</KeyEvent>
  <Script>
    (L:SaveInitialValues, bool) 1 ==
    if{
      'ZZZMetro3State.txt' scat (>C:LOGGER:openWrite)
       
      (L:VIS_Flight_Yoke, Bool) (>C:LOGGER:number)
       
      1 (>C:LOGGER:closeWrite)     
      0 (>L:SaveInitialValues, bool)   
    }
       
    </Script>
  </Trigger>
  </KeyMap>
 
I assume you'd properly written Logger\LoggerX.dll in DLL.XML path, and also the DllStart and Stop lines.

Now, in this sentece:

Code:
'D:\Flight Simulator X\Logger\Metro3_State.txt' scat (>C:LOGGER:openWrite)

you are actually passing 0.D:\Flight Simulator X\Logger\Metro3_State.txt because the scat command is joining that file path with the value of an empty stack which is 0, translated to '0.' in strings.

Remove that scat and check whether it resolves the problem or there is something else.

Tom
 
That worked, Tom.

But I've also tried the default "Macro + Filename" method and it didn't work. Do you know why?


Also, can I assign multiple "Keyevent"s to a <KeyMap> entry?
 
Last edited:
Sorry, what do you mean by "Macro+Filename" ?

And yes of course, you can assign multiple "Keyevents in a single <KeyMap>, like:


Code:
<KeyMap id="KeyMap">
   <Trigger id="x">
      <KeyEvent>EVENT1</KeyEvent>
         <Script>
        </Script>
  </Trigger>
   <Trigger id="y">
      <KeyEvent>EVENT2</KeyEvent>
         <Script>
        </Script>
  </Trigger>
</KeyMap>

Tom
 
Last edited:
Sorry, what do you mean by "Macro+Filename" ?

Robbie's default configuration.
Code:
<Macro Name="Path">'D:\FSX\Stuff\'</Macro>

@Path 'ZZZ_Metro3_State.txt' scat (>C:LOGGER:openWrite)

It never worked for me.

And yes of course, you can assigne multiple "Keyevents in a single <KeyMap>, like:
Code:
<KeyMap id="KeyMap">
   <Trigger id="x">
      <KeyEvent>EVENT1</KeyEvent>
         <Script>
        </Script>
  </Trigger>
   <Trigger id="y">
      <KeyEvent>EVENT2</KeyEvent>
         <Script>
        </Script>
  </Trigger>
</KeyMap>

Sorry, I meant multiple KeyEvents for a single script.

If not (which I suppose is the case), I'm trying to make this work with a macro. Without success so far.

I've got about 100 L: vars that need saving when the flight is saved or quit and loaded when the flight loads (haven't found a KeyEvent for that yet though).


I've read you were working on a Logger-alike module for XML Tools. Is this in any usable state for saving and loading yet?
Only if it is less touchy than the current version, of course. *Ahem* :)
 
Last edited:
Only if it is less touchy than the current version, of course. *Ahem* :)

Hi,

Logger will be included in a future XMLTools release - its the same code, and I never thought it was touchy before but this is something to look into. Tom suggested to bundle Logger with XMLTools and Robbie agreed. Good idea, only need one .dll module, not two.

The macro+filename snippet you posted looks fine. I'll think about it more, but right now, I don't know where the problem lies. The path (folder) already exists before using Logger, right? Logger will create a new file but not a new path.

If path is omitted entirely, 'ZZZ_Metro3_State.txt' (>C:LOGGER: OpenWrite)*, the file will be placed in the FSX root directory. You might try that once to see if the file is created (but its better to save them to a separate folder).

Good luck.

Bob

BTW - that is FSX XML schema? I'm not very familiar with that version.

* space included to avoid the auto smiley face icon
 
Last edited:
The macro+filename snippet you posted looks fine. I'll think about it more, but right now, I don't know where the problem lies. The path (directory) already exists before using Logger, right? Logger will create a new file but not a new path.

Yes, these were all existing folders.

If path is omitted entirely, 'ZZZ_Metro3_State.txt' (>C:LOGGER: OpenWrite)*, the file will be placed in the FSX root directory. You might try that once to see if the file is created (but its better to save them to a separate directory).

It does, and it probably is the definite way to go.

BTW - that is FSX XML schema? I'm not very familiar with that version.

Yes, it is. It looks the same in the SDK.



I've more of less got it to work now. It saves when the "Save Flight" dialog is used and loads when the flight is loaded or the "RELOAD AIRCRAFT" function is triggered.

Here's a working, generic example:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<SimBase.Document Type="AceXML" version="1,0">
  <Descr>AceXML Document</Descr>
  <Filename>SaveState.xml</Filename>
  <SimGauge.Gauge id="Gauge" ArtDirectory=".">
  <FloatPosition>0.000,0.000</FloatPosition>
  <Size>1,1</Size>
  <Update_When_Hidden>True</Update_When_Hidden>
 
  <!-- THIS SECTION RUNS WHEN THE AIRCRAFT IS INITIALLY LOADED -->
  <Update id="INIT">
  <Script>
  (L:LOAD_INIT) !
  if{ 
  'SaveFile.txt' (>C:LOGGER:openRead)
  
  (C:LOGGER:openRead) slen 0 !=
  if{ 
   
      (C:LOGGER:number)  (>L:Var1, Bool)
      }

      1 (>C:LOGGER:closeRead)
 
  1 (&gt;L:LOAD_INIT)
  }
        </Script>
  </Update>
 
 
  <!-- THIS SECTION RUNS WHEN THE FLIGHT IS SAVED! --> 
  <KeyMap id="KeyMap">
  <Trigger id="x">
  <KeyEvent>SITUATION_SAVE</KeyEvent>
  <Script>
  'SaveFile.txt' (>C:LOGGER:openWrite)
 
  (L:Var1, Bool) (>C:LOGGER:number)
 
  1 (>C:LOGGER:closeWrite)
    </Script>
  </Trigger>
  </KeyMap>
 
  </SimGauge.Gauge>
</SimBase.Document>



- Edit: Added the file presence check to the loading section for good measure.
 
Last edited:
Looks great. Glad you have it working. The @Path 'File_Name.txt' scat (>C:LOGGER: openWrite)* approach works well, so it's hard to say what the issue was when you tried.

Regards,

Bob

* space included to avoid the friendly :eek: smiley face
 
Last edited:
Maybe it was the macro formatting, but as I've said, the example in the SDK documentation looks exactly the same.
 
Hmmm. The code snippet in post #5 is straight out of your XML? Like you say .. looks perfect. I better check it out a bit more, incl FSX schema, because I just don't see anything wrong at first glance.

Thanks for mentioning this.

Bob
 
Back
Top