S89405079%HSEPM1.HSE.NL@pucc.princeton.edu (06/06/90)
>hi friends, |Am I your friend. Thank you! >i'm sorry for my last mail as it was written in turkish. >and i thank friends who sent me mail about this subject >here's my problem in english : >i'm a beginner in turbo pascal v3.00 i want to get list of files in my diskette > while my programme was running.but i can't do it. if you send a routine writte >n about it then i'll be very pleased. thanks.... > Solution: It isn't a difficult problem, here is how it can be solved: ================================================= program Test; var F:SearchRec; i:integer; begin writeln('Searching for files...'); findfirst('A:*.*',anyfile,F);i:=0; while doserror<>18 do (* No more files *) begin inc(i); writeln(i:3,' ',F.name); findnext(F); end; writeln(i,' file listed'); end. ================================================== The searchrec is already in TP3.0 (in TP4.0 and higher it's in the DOS-unit). type searchrec=record name:string[12]; (* Can be 11 *) attr:byte; (* Equal as in dos *) .... (* Some other I never use, so I don't know them *) end; doserror: 18= no more files procedure findfirst(path:string;attr:byte;var F:searchrec); path: where to search for the files (If not exists, it returns doserror 18) attr: can be: -directory (Searching for directories) -archive ( " " archives) -readonly ( " " read-only's) -hidden ( " " hidden) -volume ( " " volume-labels) -anyfile ( " " all of the above) so archive+readonly+hidden searches for readonly-hidden archives etc.. F: the returned file. procedure findnext(var F:searchrec); F: the returned file. ALWAYS: first findfirst, after that a findnext (Why should they else call it findfirst) Edwin Groothuis S89405079@hsep1.hse.nl Hoge School Eindhoven - The Netherlands