[fpc-pascal] findfirst wildcards...
waldo kitty
wkitty42 at windstream.net
Tue Dec 2 22:52:41 CET 2014
how do you process for multiple filemasks?
eg: find ts??????.sel and t???.sel for the same processing run
====== snip filemask.pas ======
Program Filemasks;
Uses
SysUtils, StrUtils, Classes;
var
dirSR : TSearchRec;
flist : TStringList;
fmask : string;
begin
if paramstr(1) <> '' then
begin
fmask := paramstr(1);
writeln('looking for files that match "'+fmask+'"');
writeln;
flist := TStringList.Create;
// try
flist.Sorted := False;
flist.Duplicates := dupIgnore;
flist.CaseSensitive := False;
if FindFirst(fmask,faAnyFile,dirSR) = 0 then
begin
repeat
flist.Add(dirSR.name);
writeln(PadRight(IntToStr(flist.count),6) + ' ' +
flist.Strings[flist.count-1]);
until FindNext(dirSR) <> 0;
{$IFDEF FPC}
findclose(dirSR);
{$ENDIF}
end;
writeln;
writeln(PadRight('found ' + IntToStr(flist.count),5) + ' files matching
"'+fmask+'"');
// finally
// if assigned(flist) then
// freeandnil(flist);
// end;
end
else
writeln('please specify a file mask - eg: *.foo');
end.
====== snip ======
as seen above, i also attempted to use try...finally in the above but fpc always
complained about the next line...
Free Pascal Compiler version 2.6.4 [2014/03/02] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: OS/2
Compiling filemask.pas
filemask.pas(19,9) Error: Identifier not found "try"
filemask.pas(19,9) Fatal: Syntax error, ";" expected but "identifier FLIST" found
Fatal: Compilation aborted
Error: X:\FP\2.6.4\BIN\OS2\ppc386.exe returned an error exitcode (normal if you
did not specify a source file to be compiled)
what am i missing?? i've never really used this capability before...
--
NOTE: No off-list assistance is given without prior approval.
Please *keep mailing list traffic on the list* unless
private contact is specifically requested and granted.
More information about the fpc-pascal
mailing list