Solved

Delphi Programming question

Posted on 1997-09-12
3
158 Views
Last Modified: 2010-04-04
How can I search for a word in a Paradox Memo or Formatted Memo?
0
Comment
Question by:rainbowsoftware
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 20 total points
ID: 1344716
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;

0
 

Author Comment

by:rainbowsoftware
ID: 1344717
This is a good code, but maybe I should learn to write exactly what I want to do. I want to search for 2 or more different words in a memo and in case not sensitive.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1344718
1. 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));
2. to find 2 words or more 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.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
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…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

22 Experts available now in Live!

Get 1:1 Help Now