Hi Dave.
I have written a simple OC function for you. I think it should help you finding the row numbers.
/**
Find the beginning and ending row index with the corresponding date in the first column.
Note that the worksheet has been sorted according to the first column.
Example:
void TestFindDataRange()
{
int iBegin, iEnd;
FindDateRange("data1", "06/05/08", iBegin, iEnd);
printf("Beginning index: %d\n", iBegin);
printf("Ending index: %d\n", iEnd);
}
Parameters:
lpcszWksName = The name of the worksheet
lpcszDate = The user-input date
iBeginning = the beginning index of the rows whose first column values are equal to the user input
iEnding = the ending index of the rows whose first column values are equal to the user input
*/
bool FindDateRange(LPCSTR lpcszWksName, LPCSTR lpcszDate, int &iBeginning, int &iEnding)
{
bool bRet=false;
bool bFound=false;
Worksheet wks(lpcszWksName);
if (!wks)
{
out_str("Cannot find the worksheet!");
return bRet;
}
bRet = true;
double dDate;
string strScript;
strScript.Format("dd=date(%s)",lpcszDate);
LT_execute(strScript);
LT_get_var("dd", &dDate); // Get LabTalk variable value
int ii;
double temp;
for (ii=0; ii<wks.Columns(0).GetNumRows(); ii++)
{
if ((wks.Cell(ii, 0)==dDate)&&(!bFound)) //Find the beginning row
{
bFound=true;
iEnding=iBeginning=ii;
}
if ((wks.Cell(ii, 0)!=dDate)&&(bFound)) //Find the ending row
{
bFound=true;
iEnding=ii-1;
break;
}
}
return bRet;
}