Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Wildcard

Posted on 1997-06-19
4
Medium Priority
?
270 Views
Last Modified: 2010-04-04
I'm trying to write a small program that will read all the files in a directory search for a certain word, if the word is found inside the text file, the program will copy the line containing the word into another text file.

I have no problem doing this on ONE file, my question is, is there a way to make the program go throught all the files with a certain extension (let's say .txt) found in a directory.

ie : is there a way to give Delphi 2.0 program the path to the directory and tell it to execute a block of code on '*.txt'

so if the directory I want searched is c:\list
and it contains the 20 files (or more) with the 'txt' extension, I want the program to go throught each one of those 20 (or more)files.

Thanks in advance
Rafy Terzian
0
Comment
Question by:rafy
[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
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 150 total points
ID: 1337247
Use the functions 'FindFirst' and 'FindNext'. This functions support wildcards.
0
 

Author Comment

by:rafy
ID: 1337248
This seems to be what I need...but it works on Ttable..
How do I place all the file names from my directory c:\list into a Ttable

What and how define all this??

Some code would be appreciated...
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1337249
when you call findfirst and findnext, the results are entered into a record of type TSearchRec, which includes data about the current file (name, size etc.).

then you call the append and set the appropriate field to
(name of TSearchRec).Name

from delphi help:
-------------------------
Unit
SysUtils
TSearchRec defines file information searched for by FindFirst or FindNext.

type
TFileName = string;
TSearchRec = record
Time: Integer;
Size: Integer;
Attr: Integer;
Name: TFileName;
ExcludeAttr: Integer;
FindHandle: THandle;
FindData: TWin32FindData;
end;


0
 

Author Comment

by:rafy
ID: 1337250
Thanks
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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

722 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