Board index » delphi » Retrieving a list of files from a directory?

Retrieving a list of files from a directory?

Hi

I am doing a computer science project for school, using Turbo Pascal 7. Our
teacher said we should improvise and add features to the program which I
asked us to create.

One of the features I am working on needs to display the files in a
directory. (Not using Turbo Vision).

In Visual Basic you can do this with the Dir([Filter]) function, i.e.

x = Dir("c:\*.txt")

Is there a similar function in pascal that would allow me to call each file
one-by-one? Reference to where I can find such a funciton in the help file,
or sample code would be great.

Regards

Crush Depth

 

Re:Retrieving a list of files from a directory?


Quote
> I am doing a computer science project for school, using Turbo Pascal 7. Our
> teacher said we should improvise and add features to the program which I
> asked us to create.

> One of the features I am working on needs to display the files in a
> directory. (Not using Turbo Vision).

> In Visual Basic you can do this with the Dir([Filter]) function, i.e.

> x = Dir("c:\*.txt")

> Is there a similar function in pascal that would allow me to call each file
> one-by-one? Reference to where I can find such a funciton in the help file,
> or sample code would be great.

   Yes.  FindFirst/FindNext will retrieve files (according to the mask
used) and using a loop will allow you to obtain information about all of
them.  Also, the Exec procedure will allow you to execute the DOS Dir
command and collect its output.

Re:Retrieving a list of files from a directory?


Quote
Crush Depth wrote:

Besides the ideas, which Mike Copeland already has written:

http://bsn.ch/tp-links
page "FAQ" look for "Recursion example, program SUCHE". It may
be helpful, but it is more than you desired: it can scan a whole
directory tree.
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation
http://members.eunet.at/meg-glaser/    http://members.xoom.com/f_glaser/
http://www.geocities.com/~franzglaser/            http://start.at/bedarf

Re:Retrieving a list of files from a directory?


Thanks for the reply!
I'll look up FindFirst and FindNext in the help file.

Regards

Crush Depth
Ing. Franz Glaser <meg-gla...@eunet.at> wrote in message
news:38179747.FEAFAC3B@eunet.at...

Quote
> Crush Depth wrote:

> Besides the ideas, which Mike Copeland already has written:

> http://bsn.ch/tp-links
> page "FAQ" look for "Recursion example, program SUCHE". It may
> be helpful, but it is more than you desired: it can scan a whole
> directory tree.
> --
> Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
> Muehlviertler Elektronik Glaser.  Industrial control and instrumentation
> http://members.eunet.at/meg-glaser/    http://members.xoom.com/f_glaser/
> http://www.geocities.com/~franzglaser/            http://start.at/bedarf

Re:Retrieving a list of files from a directory?


Hi!

There is an example program called DIRDEMO.PAS . Should be supplied along
with your TP/BP paket.

CU
Jens

--
[ MY WEBPAGES (IN GERMAN AND ENGLISH) ]

[ HOMEPAGE: http://home.t-online.de/home/jens.gesing/index.htm ]
[ PROGRAMMING-DO-IT-YOURSELF: http://members.xoom.com/goldman47/index.htm ]
[ EMAIL: jensi_...@gmx.de ]

Re:Retrieving a list of files from a directory?


I didn't read the original message, but i beleive this suits the need
of the subject. This is a thing i wrote back then to add file_id.diz
to bbs files, or add arj.. i forgot . enver mind
this thingie finds all files that ends with arj and execute a dos
command on them.
u use the varailable  var dirinfo:searchrec;
and Archive is a const of i remember correctly
you find first file (FINDFIRST) and then find the rest with FINDNEXT
Vewy Vewy easy
FindFirst('*.ARJ', Archive, DirInfo);
while DosError = 0 do
begin
  clrscr;
  Writeln(DirInfo.Name);
  sound(220);
  delay(50);
  nosound;
  v:='/c c:\dos\arj.exe a '+dirinfo.name+' '+s;
  swapvectors;
  exec('c:\command.com',v);
  swapvectors;
  FindNext(DirInfo);
end;

On Thu, 28 Oct 1999 12:52:18 +0200, "Jens Gesing" <jensi_...@gmx.de>
wrote:

Quote
>Hi!

>There is an example program called DIRDEMO.PAS . Should be supplied along
>with your TP/BP paket.

>CU
>Jens

>--
>[ MY WEBPAGES (IN GERMAN AND ENGLISH) ]

>[ HOMEPAGE: http://home.t-online.de/home/jens.gesing/index.htm ]
>[ PROGRAMMING-DO-IT-YOURSELF: http://members.xoom.com/goldman47/index.htm ]
>[ EMAIL: jensi_...@gmx.de ]

choKari!

Other Threads