SimConnect_AddToDataDefinition - using RPN to set LVar - SOLVED see last post

The documentation states:

It is possible to get and/or set an RPN “L” variable through SimConnect using the SimConnect_AddToDataDefinition function, for example:

SimConnect_AddToDataDefinition(hSimConnect, DataDefinitionID, “L:VARIABLE_NAME”, “number”, SIMCONNECT_DATATYPE_FLOAT64);

Yet their example just presents what appears to be a default statement. If there’s RPN notation in there, I don’t see it.

I’m trying to set L:XMLVAR_ADF_Mode to a value:
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, “L:XMLVAR_ADF_Mode”, “number”, SIMCONNECT_DATATYPE_FLOAT64);

And I can’t figure it out by reading the “explanations” on the RPN page.

Robert

C++
VS2022

The example is just showing the syntax so yours just needs SIMCONNECT_DATATYPE_FLOAT64 replacing with the number you want to set. So it’s LVAR name, data type, value.

It seems so simple, and yet.

I tried with 0, “0”.
I tried a int with value 0, a pointer to the int.
Same with float, nothing works.

float NewValue = 3;
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, L:XMLVAR_ADF_Mode, number, &NewValue);

Note this is C++ in VS2022. Running out of ideas…

So I looked at the detailed structure in the SDK and tried a bunch of stuff with all the fields populated:
HRESULT SimConnect_AddToDataDefinition(
HANDLE hSimConnect,
SIMCONNECT_DATA_DEFINITION_ID DefineID,
const char* DatumName,
const char* UnitsName,
SIMCONNECT_DATATYPE DatumType = SIMCONNECT_DATATYPE_FLOAT64,
float fEpsilon = 0,
DWORD DatumID = SIMCONNECT_UNUSED
);

Tried:
hardcode 0, “0”,
int NewValue = 0
dword, and float

SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, L:XMLVAR_ADF_Mode, number, SIMCONNECT_DATATYPE_FLOAT64, 0, NewValue);
Also tried passing pointers, still nothing,

AM I MISSING A SUBSEQUENT COMMAND THAT MUST BE USED TO ACTIVATE THE CHANGE?
D’uh, hadn’t thought of that…

I’m using FSUIPC7 in parallel to see if the value changes, nada every time.

Robert
:smiley:

I don’t program in raw simconnect so I can’t really help with that but I did notice that your original example had the LVAR inside “” quotes. The later ones you said you tried did not.

[quote="Sling380, I don’t program in raw simconnect so I can’t really help with that but I did notice that your original example had the LVAR inside “” quotes. The later ones you said you tried did not.
[/quote]

Nah, it truly wants those quotes. I just tried and it threatened me with unspeakable violence. :smiley:

Same with “number”, it seems to want those too.

Robert

Do you use a secondary command to “activate” the change?

Nope. It just sends that specific sim event in the one line.No idea if you need something like that when using sim connect directly.

Solved here!

https://devsupport.flightsimulator.com/questions/16496/setting-xmlvar-adf-mode-using-addtodatadefinition.html