KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: The 4D Open APIs - Part VIII: Searching records with 4D Open (sample code)
PRODUCT: 4D | VERSION: 6.7 | PLATFORM: Mac & Win
Published On: August 31, 2001
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

The code below allows you to retrieve records from table 1, field 4. This field is an integer field and we're going to search for all records with the value 999.

The code to be used is:

void SearchRecords(void)
{
 SearchRecordPtr pSearch = (SearchRecordPtr) malloc(sizeof(SearchRecord));
 DataRec data;
 int4 nbRec;
 data.typ = s_Int16;
 data.u.i = 999;
 printf("Searching records , field #4 = 999 \n");
 pSearch->NB_Lines = 1;
 pSearch->TargetFile = 1;
 pSearch->lines[0].Field_Number = 4;
 pSearch->lines[0].File_Number = 1;
 pSearch->lines[0].SOP = Equal;
 pSearch->lines[0].Value = data;
 pSearch->lines[0].LOP = None2;
 Check(_4D_Search(hConnect, pSearch, &nbRec),"_4D_Search\0");
 free(pSearch);
 printf("found %ld records matching = 999\n", nbRec);
}