Hi,
I'm creating a PBNI using the SDK and C. I would like to know how I can create a multi dimensional pbarray and set it's values. I have a single dimension array working fine but can't figure out what to create a 2 dimensional pbarray.
pbarray sgpinterface::floatArrayToPBArray(IPB_Session * session, float data[], int size) {
pbuint numDimensions = 1; // Set This To 2 For 2D Array
PBArrayInfo::ArrayBound bound;
bound.lowerBound = 1;
bound.upperBound = size;
pbarray dataArray = session->NewBoundedSimpleArray(pbvalue_dec, numDimensions, &bound);
pblong dim[1];
for (int i = 0; i < size; i++) {
dim[0] = i + 1; // What Should This Be For 2D Reference?
float floatVal = data[i];
char b[100];
sprintf_s(b, 100, "%f", floatVal);
pbdec decval = session->NewDecimal();
session->SetDecimal(decval, (LPCSTR)b);
session->SetDecArrayItem(dataArray, dim, decval); // How To Use Dim Here To Set 2D Array Value?
}
return dataArray;
}
long ll_long_array [4,5,6] // 3 dimensional fixed dimensions array example
long ll_long_variable[] // 1 dimensional variable dimension array
As far as I know you cannot create a variable length multidimensional array.
(The fact that multidimensional arrays have to be of a predefined size has never made them very useful to me).
For more complicated stuff I prefer using a datastore which has the advantage of being able to sort, filter, find, etc.
int multi[4][5][6];