home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOOL_INC.ZIP / GETFILE3.INC < prev    next >
Encoding:
Text File  |  1988-01-29  |  1.4 KB  |  62 lines

  1.  
  2. (*
  3.  * getfile2 - file list processing library (simplified version)
  4.  *
  5.  * This module will change a wildcard list of files into a
  6.  * sorted file name list.
  7.  *
  8.  * Samuel H. Smith, rev. 25-oct-87
  9.  *
  10.  *)
  11.  
  12. procedure getfiles (pattern:       string;
  13.                     var fdir:      filearray;
  14.                     var num:       integer);
  15. var
  16.    i:             integer;
  17.    curdir:        string;
  18.    keyword:       string13;
  19.    doscan:        boolean;    {can dos do this wildcard?}
  20.    DirInfo:       SearchRec;
  21.  
  22. begin
  23.    stoupper(pattern);
  24.    curdir := path_only(pattern);
  25.    keyword := remove_path(pattern);
  26.  
  27.    doscan := true;
  28.    i := pos('*',keyword);
  29.    if i > 0 then
  30.       if (keyword[i+1] <> '.') and (i < length(keyword)) then
  31.          doscan := false;
  32.  
  33.    if doscan = false then
  34.       pattern := curdir + '*.*';
  35.  
  36.    num := 0;
  37.    FindFirst(pattern,$21,DirInfo);
  38.  
  39.    while (DosError = 0) and (num < maxnumfiles) do
  40.    begin
  41.       if doscan then
  42.       begin
  43.          inc(num);
  44.          savestr(fdir[num],curdir + DirInfo.name);
  45.       end
  46.       else 
  47.  
  48.       if wildcard_match(keyword, DirInfo.name) then
  49.       begin
  50.          inc(num);
  51.          savestr(fdir[num],curdir + DirInfo.name);
  52.       end;
  53.  
  54.       FindNext(DirInfo);
  55.    end;
  56.  
  57.    if num >= maxnumfiles then
  58.       writeln('Warning:  Files in excess of ', maxnumfiles, ' ignored.');
  59.  
  60. end;                     {getfiles}
  61.  
  62.