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?
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?
