Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Use a Pointer to reference Datatables


creisinger Oct 29, 2021 04:41 PM

I am needing to dynamically call different tables to copy data from them and combine into a single array. But I want to store the memory locations to an array:

SensorDataAddress(1) = @Datatable1.Param(1,1)
SensorDataAddress(2) = @Datatable2.Param(1,1)
SensorDataAddress(3) = @Datatable3.Param(1,1)

Then I have a loop to consolidate them:

HS_RegCopyStartPos = 1
For i = 1 To HowManySensors
TempHSpntr = SensorDataAddress(i) 'Move pointer from array to temp since cannot reference array locations
For j = 1 To SensorNumParams(i)
HS_Data(HS_RegCopyStartPos) = !TempHSpntr
'Update Array index and Pointer address for next datapoint
HS_RegCopyStartPos += 1
TempHSpntr += 1
Next j

I know the loop works because if I map the Pointer array to the raw data it works:

SensorDataAddress(1) = @Sensor1Params(1)
SensorDataAddress(2) = @Sensor2Params(1)
SensorDataAddress(3) = @Sensor3Params(1)

The Address array is used in multiple places for various things so I don't want to hardcode it or have a bunch of If statements pointing to the specifc table for each sensor. I tried using a pointer to move the datatable name in as well but it had issues with the dimensions not lining up

Thanks, any help would be appriciated

Log in or register to post/reply in the forum.