Solved

Search Memo on filtered database

Posted on 2002-03-25
2
145 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
ID: 6896431
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
ID: 6898714
Just the trick !
Thanks
Paul.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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