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

WASM code improvements

I have a good working WASM that I use in MSFS. As I now need to make another WASM and reuse the code, but this time with another large list of different LVars, I am looking for a way to improve my rather unprofessional coding.

In a header file, I have a complete list of all LVars.

These LVars need to be registered at the start to find the id number at run time.

Here is an example of how I register an LVar:
A32NX_METRIC_ALT_TOGGLE_id = check_named_variable("A32NX_METRIC_ALT_TOGGLE");
This same type of code line I have for hundreds of LVars, the only difference is the name of the LVar.

How can I improve this so I don't need to write hundreds of lines that are more or less the same?

The same large number of LVars values need to be updated to a data structure.

Here is an example of how I update an LVar value in the data structure:

sA32NX_LVAR_Data.A32NX_METRIC_ALT_TOGGLE = (int)get_named_variable_value(A32NX_METRIC_ALT_TOGGLE_id);

How can I improve this so I don't need to write hundreds of lines that are more or less the same?
After some head-scratching I come up with this solution to my first question:

std::vector<int> vVars;

int i;
for (i = 0; i < LENGTHOF(VarNames); i++)

vVars.push_back (check_named_variable(VarNames));


This code should get all LVar ids to a vVars vector.

Now I only need to find a way to update the A32NX_LVAR_Data structure.

Any suggestion?
Last edited: