DragonflightDesign
Resource contributor
- Messages
- 1,368
- Country

This is my first attempt at creating and reading a data definition dynamically. It all works well insofar that the data definition is created and that 'RequestDataOnSimObject' is fired off because
gets hit successfully. The syntax problem occurs when trying to get data out of the definition and into a receiving struct - what is a perfectly legal call for a non-dynamic definition is barfing on the dynamic one with a
It's the very last line in the code below. Stack Overflow has completely failed to give me code that I can cut'n'paste without understanding what's going on.
Seriously though, what should I be doing?
Thank you.
Code:
if (pObjData->dwRequestID == REQUEST_PAYLOAD_INFO)
Code:
Error C2679 binary '=': no operator found which takes a right-hand operand of type 'payloadData' (or there is no acceptable conversion)
Seriously though, what should I be doing?
Code:
// No. of stations
struct payloadStations
{
double stations;
};
payloadStations pStations;
// Station definition
struct payloadData
{
float stations[];
};
// Receiving structure
struct payloadInfo
{
double station1;
// etc..
};
payloadInfo pStatWeight;
// ----------------------
if (pObjData->dwRequestID == REQUEST_PAYLOAD_STATIONS)
{
int i = 0;
char station[64] = "";
payloadStations* pStationData = (payloadStations*)&pObjData->dwData;
pStations = *pStationData;
// Create a definition for payload station weights
if (pStations.stations != 0)
{
// Allocate and size the station data structure
payloadData* pStationData = (payloadData*)malloc(sizeof(float) * pStations.stations);
// Build the data definition
for (i = 1; i <= pStations.stations; i++)
{
sprintf (station, "PAYLOAD STATION WEIGHT:%d", i);
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINE_PAYLOAD_INFO, station, "pounds", SIMCONNECT_DATATYPE_FLOAT64);
}
hr = SimConnect_RequestDataOnSimObject(hSimConnect, REQUEST_PAYLOAD_INFO, DEFINE_PAYLOAD_INFO, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SECOND, NULL, NULL, NULL, NULL);
}
}
if (pObjData->dwRequestID == REQUEST_PAYLOAD_INFO)
{
payloadData* pPData = (payloadData*)&pObjData->dwData;
pStatWeight = *pPData; // <--- Syntax error here
}
Thank you.
