Solved

Wildcard

Posted on 1997-06-19
4
267 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

623 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