Solved

Scripts for open a document a find its keyword

Posted on 2003-11-26
9
222 Views
Last Modified: 2010-04-05
anyone has scripts that can search for keywords for a document?  or  scripts that can search a document by giving a phrases or sentences in the document, e.g. advanced search function in windows.

thank yuou!!!
0
Comment
Question by:jiekuan
[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
  • 4
  • 3
  • 2
9 Comments
 
LVL 2

Expert Comment

by:TheLeader
ID: 9830025
it needs more points than you just set
but heres a solution from million ;)

procedure findmore;
begin
   find (Masked {.txt,log,...) files
   open each file
   search the word
   if matched word then exit
   else
   findmore
end
hope it helped...
0
 

Author Comment

by:jiekuan
ID: 9833467
TheLeader, the algorithm you post is correct, can i have more precise solution, maybe the exact code , thank you. btw i have increased point to 100.
0
 

Author Comment

by:jiekuan
ID: 9833476
e.g.  what is the code for  "search the word" ...etc
0
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!

 
LVL 2

Accepted Solution

by:
TheLeader earned 100 total points
ID: 9835033
well i made it very Simple,to let you change the code easily
if you would like the complete project by Email, its ok
any way this is the code

{**********************************************}

unit fileU;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, FileCtrl, StdCtrls;

type
  TForm1 = class(TForm)
    DriveComboBox1: TDriveComboBox;
    DirectoryListBox1: TDirectoryListBox;
    FileListBox1: TFileListBox;
    FilterComboBox1: TFilterComboBox;
    Button2: TButton;
    Edit1: TEdit;
    Button1: TButton;
    Edit2: TEdit;
    Edit3: TEdit;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;

Function SearchWord(F,Word : String): Boolean;
Var
  Temp : String;
  FileName : TextFile;
  I : Integer;
Begin
  Assign(Filename,F);
  Reset(Filename);
  While Not EOF(Filename) Do
  Begin
    Readln(Filename,Temp);
    I := Pos(Word, Temp);
    IF I > 0 Then
    Begin
      Result := True;
      Close(Filename);
      Exit;
    End;
  End;
  Result := False;
  Close(Filename);
End;

procedure TForm1.Button1Click(Sender: TObject);
Var I : Integer;
begin
IF filelistbox1.Items.Text <> '' Then
For I := 0 To Filelistbox1.Items.Count-1 DO
  IF SearchWord(DirectoryListBox1.Directory +'\' + Filelistbox1.Items.Strings[i]
                ,Edit2.Text) Then
  Begin
    Edit3.Text := 'YES';  // yes I Found the word
    Filelistbox1.Selected[I] := true; // to show you which file it has the word
    Break;
  End
  Else
    Edit3.Text := 'No' // No I Did't Found it
else
  edit3.Text := 'I Can''t make a search'; // Theres No Files
//  Edit2.Text := ;
End;

end.
0
 
LVL 2

Expert Comment

by:TheLeader
ID: 9844332
"jiekuan" accept my answer or leave a comment !!!
0
 

Author Comment

by:jiekuan
ID: 9894263
sorry to TheLeader, i have been overseas for past one week. not accessible to internet
0
 

Expert Comment

by:plovel
ID: 9919056
TheLeader, em..   what i wan is to open document files ( .txt and .doc) and examine all words inside the docuemnt. then find out the keyword of the document ( i.e.  most occurence frequencies, any other criteria )..
0
 

Expert Comment

by:plovel
ID: 9934275
check your email, i have sent you a tutorial file for this.
0
 

Author Comment

by:jiekuan
ID: 9934320
TheLeader, can i have your email address, so that i can consult you for more, thank you
0

Featured Post

Technology Partners: 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

Title # Comments Views Activity
delphi parse string to params 3 178
DBGrid or StringGrid ? 6 137
Delphi, TImage, Png 2 57
Problem working with dynamic array - help 2 49
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 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