Solved

Wildcard

Posted on 1997-06-19
4
263 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
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IExtractImage Delphi 14 198
Activex get website that activex running on 3 85
How to fill array with TArray.Create? 14 77
DBGrid or StringGrid ? 6 62
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…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

932 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

8 Experts available now in Live!

Get 1:1 Help Now