SimConnect_AddToDataDefinition(hSimConnect, 10, "ELEVATOR TRIM POSITION", "Radians", SIMCONNECT_DATATYPE_FLOAT64);
SimConnect_ClearDataDefinition(hSimConnect, 10);
SimConnect_AddToDataDefinition(hSimConnect, 10, "ELEVATOR TRIM POSITION", "Radians", SIMCONNECT_DATATYPE_FLOAT64);
Then I go to MSFS → Devmode → Tools → SimConnect Inspector → select my client from the dropdown → on the Data Definitions tab I select 10 from the dropdown → I see two lines (Pos 0 and 1) both with Name “ELEVATOR TRIM POSITION”.
I expect ClearDataDefinition to remove my first data definition and at the end I expect to see only 1 definition on the Data Definitions tab.
You are right, ClearDataDefinition removes the content of the specified DataDefinition and works as expected.
However, the SimConnect Inspector doesn’t refresh itself if this function is called, that’s why you see two lines even if there is, in reality, only one entry.
If you open the Inspector once your code has been executed, you should see only one line.
I tested it and it works a bit strange. Here is what I did:
Start a flight.
Execute my example code above.
Open Inspector.
Indeed I see only one data definition, whereas previously I saw two.
Close Inspector.
Execute my code again.
Open Inspector.
Now I see two data definitions.
After this, every time I repeat the last 4 steps a new data definition is added to the list. So what you said is only true until the first opening of the Inspector and after that it starts to accumulate new lines, no matter if it is closed or opened.
If possible, please fix this by updating the Inspector when ClearDataDefinition is called.