home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / Chip_2000-02_cd.bin / zkuste / Delphi / navody / tt / objvm.exe / UNITS / DIrs.pas < prev    next >
Pascal/Delphi Source File  |  1998-04-26  |  1KB  |  45 lines

  1. unit Dirs;
  2.  
  3. interface
  4. Uses SysUtils;
  5. function OriginDir:string;
  6. function OriginDirFile(const s:string):String;
  7. function DirFile(const s,f:string):string;
  8. function UniqueFile(const Dir,Prefix,Suffix:string):string;
  9. implementation
  10. function OriginDir;
  11.          begin
  12.            OriginDir:=ExtractFilePath(ParamStr(0));
  13.          end;
  14. function OriginDirFile;
  15.          Var ss:STring;
  16.          begin
  17.            ss:=OriginDir;
  18.            if ss[Length(ss)]='\' then
  19.              OriginDirFile:=ss+s
  20.            else
  21.              OriginDirFile:=ss+'\'+s;
  22.          end;
  23. function DirFile(const s,f:string):string;
  24.          begin
  25.            Result:=S;
  26.            if s[length(s)]<>'\' then
  27.            begin
  28.              Result:=Result+'\';
  29.            end;
  30.            Result:=Result+f;
  31.          end;
  32. function UniqueFile(const Dir,Prefix,Suffix:string):string;
  33.          Var i:integer;
  34.          begin
  35.            i:=0;
  36.            Result:=DirFile(Dir,Prefix+IntToStr(i)+Suffix);
  37.            While FileExists(Result) do
  38.            begin
  39.              inc(i);
  40.              Result:=DirFile(Dir,Prefix+IntToStr(i)+Suffix);
  41.            end;
  42.          end;
  43.  
  44. end.
  45.