Solved

Searching in a DBMemo field

Posted on 1997-11-05
3
247 Views
Last Modified: 2010-04-04
Does anyone have any code that will allow me to search in a DBMemo field.

Thanks
0
Comment
Question by:dl090597
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 50 total points
ID: 1349605
The following deals with TMemo, but it should work also with TDBMemo:

Place a TMemo on a form and try this one, it's case sensitive:

procedure TForm1.Button1Click(Sender: TObject);
var FText: string;
size: integer;
Buffer, FindBuf: PChar;
A: array[0..255] of char;
begin
if InputQuery('Find Text', 'Enter text to find:', FText) then
  with memo1 do begin
    setfocus;
    size:=gettextlen+1;
    GetMem(Buffer,Size);
    GetTextBuf(Buffer,Size);
    FindBuf:=StrPos(Buffer,strPCopy(A,FText));
    if FindBuf<>nil then
    begin
      selstart:=Size-StrLen(FindBuf)-1;
      sellength:=length(FText);
    end
    else
      showmessage('not found');
    FreeMem(Buffer,Size);
  end;
end;

to make the search in case not sensitive write:                             FindBuf:=StrPos(strupper(Buffer),strupper(strPCopy(A,FText)));
instead of
  FindBuf:=StrPos(Buffer,strPCopy(A,FText));
0
 

Author Comment

by:dl090597
ID: 1349606
Thanks ronit for the above solution, what I need to also do is to implement a find again option, i.e. I might have two or more occurences of the same word I am looking for in the dbmemo, and I need the user to be able to search again in the same memo, any code would be appreciated
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1349607
To do find next expand this basic procedure for your own needs, say run this procedure a number of times as the number of words you need to find, so that each time you load to a buffer the rest of the text, needed to be searched (that is from cursor position to the end of the memo).
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

617 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