The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



SearchData


Unit:SDL_geodb
Class:TGeoDB
Declaration:[1] function SearchData (Name: TgdbName; ItemType: TgdbItem; StartSearchAt: integer; ClassNumber: byte): integer;
[2] function SearchData (Name: TgdbName): integer;

The method SearchData searches the database for specific data. The method is available in two overloaded versions. While version [1] allows to specify the search condition in full detail, version [2] performs a simple search for names. In version [1] the search is started at the database entry StartSearchAt, version [2] always searches the entire database.

The parameter Name specifies the name of the item to be searched. The search for names is by default a substring search. In order to force an exact match the Name parameter has to start with an equality symbol (which is ignored by the search). The search is always case insensitive (even when forcing an exact match). ItemType specifies the kind of database entry, and ClassNumber the class number which has to be matched.

Each of the search parameters offers the possibility to ignore it by setting it to a special value:

Parameter Ignore Value
Name '' (empty string)
ItemType gitUndefined
ClassNumber 255

The function SearchData returns the database entry number of the found database entry. A zero value indicates that no such data has been found.

Hint: Please note that searching for geographical positions and for item IDs is not supported by SearchData since there are better and faster alternatives (GetClosestLatHighIx, GetClosestLatLowIx, GetClosestLongHighIx, GetClosestLongLowIx, and GetClosestItemIDIx)

Example: The following example shows how to search through the entire database. The variable SearchText contains the (sub)string to be searched. There are no restrictions regarding the kind of database items or the class number.
var
  NextSearchPos : integer;
  SearchText    : string;

...
...
NextSearchPos := 0;
while NextSearchPos <> -1 do
  begin
  NextSearchPos := GDB.SearchData (SearchText, gitUndefined,
                                   NextSearchPos+1, 255);
  if NextSearchPos <> 0 then
    begin
      // process the search result
    end;
  end;
...
...

Example: This method is used in the following example program (see http://www.lohninger.com/examples.html for downloading the code): geodata



Last Update: 2023-Dec-13