Solved

Delphi Programming question

Posted on 1997-09-12
3
177 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

680 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