Hi Ibex,
I suggest you use Origin C DataRange and XYRange class to get number of XY ranges and access columns in range, since there are many useful range relative functions in Origin C.
ra is a Range variable in GetRanges XFunction, right? If so, please change variable type to XYRange, and type "I:40" in Option String column in XFunction builder for this variable. I:40 use to specified this XYRange to support multiple XY ranges and Y error. More about Option String please refer to X-Function programming Help -> Create New X-Function in X-Function Builder -> Optional Strings page.
The following Origin C code shows how to get the number of XY ranges, get the columns index from range and get x, y, yErr numeric data from ranges. Copy codes to XFunction GetRanges function body and compile.
DWORD dwRules = DRR_GET_DEPENDENT | DRR_NO_FACTORS;
int num = ra.GetNumData(dwRules);
for(int nRange = 0; nRange < num; nRange++)
{
DataRange drSub;
DWORD dwRules = DRR_GET_DEPENDENT | DRR_NO_FACTORS;
ra.GetSubRange(drSub, dwRules, nRange);
if( drSub )
{
// example to the index of column X, Y, Y error
int nXCol, nYCol, nYErrCol;
Worksheet wks;
int r1, c1, r2, c2;
drSub.GetRange("X", r1, c1, r2, c2, wks);
nXCol = c1;
drSub.GetRange("Y", r1, c1, r2, c2, wks);
nYCol = c1;
drSub.GetRange("ED", r1, c1, r2, c2, wks);
nYErrCol = c1;
// example to show how to get data
vector vx, vy, verr;
drSub.GetData(dwRules, 0, NULL, NULL, &vy, &vx, NULL, NULL, NULL, &verr);
}
}
Iris