Hi Mike,
I am also new at this and although it is not the quickest way to search
for records the only way I have been able to find a record is to a linear
search. In this function a user taps on a patient name which assigns their
unique PersonSer string to a global variable SelectedPersonSer, this
function is then called which searches the gDiagnosisDB using StrComapre to
find the matching record and returning the RecordNumber. It is isn't very
elegant but it does the Job.
Brian
static Int DiagFindPersonSer(void)
{
CharPtr strPersonSer;
UInt DiagNumRecords, foundit;
UInt recordNum = 0;
VoidHand recordH;
PackedDiagnosis *packedP;
Diagnosis rec;
Diagnosis *recordP = &rec;
DiagNumRecords = DmNumRecords(gDiagnosisDB);
for (recordNum = 0; recordNum < DiagNumRecords; recordNum++)
{
recordH = DmQueryNextInCategory (gDiagnosisDB,
&recordNum,CurrentCategory);
packedP = MemHandleLock(recordH);
UnPackDiagnosis(recordP, packedP);
strPersonSer = MemPtrNew(StrLen(recordP->personSer)) ;
StrCopy(strPersonSer, recordP->personSer);
foundit = StrCompare(strPersonSer,SelectedPersonSer);
if (!foundit)
RecordNumber = recordNum;
MemPtrFree(strPersonSer);
break;
}
else
MemPtrFree(strPersonSer);
}
MemHandleUnlock(recordH);
return RecordNumber ;
----- Original Message -----
From: Mike Davis <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 20, 1999 6:38 PM
Subject: How to find Index of Record?
> I have a list of records within a category, say 5 total.
>
> Now, I want to delete the 4th record, in this list, from the
> database. But that record is not at index 4 in the database, I
> don't think. It might be 20, or 40 or 100.
>
> How do I find the index, to use in DmDeleteRecord?
>
> I have looked at DmQueryNextInCategory but that would require
> some kind of loop. DmQueryNextInCategory (docs) suggest using
> DmPositionInCategory but that returns the position in my list
> assuming I know the index. I already know the position in the
> list it is the index I need to find.
>
> Can someone help explain this?
>
> Thanks
>
>
> --
> -----------------------------------------------------------------
> Discussion Group: http://www.halcyon.com/ipscone/wwwboard/
>
> Protect your constitutional rights. Your favorite one may be next!
> -----------------------------------------------------------------
>