The main reason for sorting files with indexes is that it allows for very fast searching on the field of the first sort level.
This routine needs a 'special' parameter, which has to be of the type defined by the first sort level. It returns the indexid of the first record which equals the given item which has to be found. Subsequent records with the same value can be found with the NEXTrec command.
Sbasic record = indexFIND(#bufferid, item) item : 'special' Assembler IFND bufferid 'special' item to find return long recordid C long DDindexfind(long bufferid, char *special[8], long *return); errors, code, meaning itnf -7 invalid bufferid or not found (return=-1)
The main reason for sorting files with indexes is that it allows for very fast searching on the field of the first sort level. As mentioned above, DATAdesign has a very fast way of finding records through the INDEXfind command. This allows you to find the first record where the indexed field is equal to the search criterion.
However, this could conceivably be a problem when one wants to search for a string which is not the total of the 8 bytes used in the index. Suppose that one wants to search for all records where the indexed field starts with "DATA" one couldn't use INDEXfind to do this, as it would not find the records where the indexed field contaings , e.g., 'DATAdesign', it would only find those where the field is exactly 'DATA' because the search criterion has to match the index criterion exactly (so the search criterion for INDEXFind needs 8 bytes).
Here, INDEXFinDString may help, provided that the string to search for is a part of the string in the file, and provided that it IS LOCATED AT THE BEGINNING OF THE STRING TO BE FOUND: so, using INDEXFinDString, one would find "DATAdesign" when searching for "Data", but NOT when searching for "ata".
PLEASE NOTE:
INDEXFinDString will only work correctly on indexes built on TEXT (char) fields. If you use it for other fields, such as shorts or doubles etc, it won't work - an error is returned
This routine needs a string parameter. It returns the indexid of the first record which equals the given item which has to be found. Subsequent records with the same value can be found with the NEXTrec command.
Sbasic record = INDEXFINDString(#bufferid, string$) string$ : string to find Assembler IFND bufferid string string to find (0 terminated) return long recordid C long DDindexfind(long bufferid, char *string[8], long *return); errors, code, meaning itnf -7 invalid buffer/indexid orng -4 field was not a char/text field ipar -15 there was no string given eof -10 no matching record was found