Solved

Search Memo on filtered database

Posted on 2002-03-25
2
143 Views
Last Modified: 2010-04-04
I am using Topaz V7.51 BDE replacement (www.softsci.com)

The software has a procedure to search on a memo field for a string -
 
LocateRec(FieldName:string; var FieldValue);

e.g.
.....
var
 MyString: string;
begin
 MyString := 'A Company';
 MyTable.LocateRec('COMPANY', MyString);
......

if the search string is found a call to another

procedure Continue;

e.g.
.....
 MyTable.Continue;
.....

resumes the search for another occurance of the string. This can be called repeatedly until the end of the database is reached.
The problem is that the procedure does not respect filters and i wish to search on filter ranges. I have found an undocumented function used internally by Topaz to detect if the current record is in the filter range.

function RecordInFilterRange: Boolean

I wish to use this to detect if a matching string is in the filter range, If it is in the filter range stop then a call can be made to Continue or if it is not ignore it and continue to the next match etc. I wish to use 2 buttons (Locate & Continue) to achieve this functionality.
 Any help would be appreciated.

Regards
Paul.  
0
Comment
Question by:pr_wainwright
2 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 150 total points
Comment Utility
Hi,
Something like:

// locates first record within a range
// returns true = found and false = not found
function LocateRecFiltered(TheTable: TypeOfMyTable; FieldName:string; var FieldValue): boolean;
begin
 result := false;
 try
  with TheTable do begin
   LocateRec(FieldName, FieldValue);
   if not EOF then begin
    while (not EOF) and (not RecordInFilterRange) do begin
      Continue;
    end;
    if not EOF then result := true;
   end;
  end;
 except
  result := false;
 end;
end;

// continues searching
// returns true = found and false = not found
function ContinueFiltered(TheTable: TypeOfMyTable): boolean;
begin
 result := false;
 try
  with TheTable do begin
   Continue;
   if not EOF then begin
    while (not EOF) and (not RecordInFilterRange) do begin
      Continue;
    end;
    if not EOF then result := true;
   end;
  end;
 except
  result := false;
 end;
end;

Usage:
// Locate button
procedure TForm1.Button1Click(Sender: TObject);
begin
  if not LocateRecFiltered(MyTable, 'COMPANY', Edit1.Text) then ShowMessage('Record not found');
end;

// Continue button
procedure TForm1.Button2Click(Sender: TObject);
begin
  if not ContinueFiltered(MyTable) then ShowMessage('There are no more records found');
end;

Replace 'TypeOfMyTable' with the actual type in both function definitions. I presume that there are MyTable.EOF property and MyTable.RecordInFilterRange method.

Regards, Geo
0
 
LVL 1

Author Comment

by:pr_wainwright
Comment Utility
Just the trick !
Thanks
Paul.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now