home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / TURBOPAS / FNAME.LBR / FNAME.MOD < prev   
Text File  |  2000-06-30  |  1KB  |  39 lines

  1. IMPLEMENTATION MODULE FNAME;
  2.  
  3. (*  useful routines for manipulation of filenames.  By Glenn Brooke
  4.     12/29/86, released to the public domain.
  5. *)
  6.  
  7. FROM strings   IMPORT Length, Pos, Append, Copy, Delete;
  8.  
  9. PROCEDURE AppendExt(VAR DiskFileName : filename; Ext : Extension);
  10. (* appends the extension Ext to the filename DiskFileName *)
  11. VAR
  12.     LengthCount : CARDINAL;
  13. BEGIN
  14.   LengthCount := Length(DiskFileName);
  15.   DiskFileName[LengthCount] := ".";
  16.   Append(Ext, DiskFileName);
  17. END AppendExt;
  18.  
  19.  
  20. PROCEDURE StripExt(VAR DiskFileName : filename);
  21. (* strips the period and following characters *)
  22. VAR WherePeriod : CARDINAL;
  23. BEGIN
  24.   WherePeriod := Pos(".", DiskFileName);
  25.   Delete(DiskFileName, WherePeriod, Length(DiskFileName)-WherePeriod);
  26. END StripExt;
  27.  
  28.  
  29. PROCEDURE GetExt(DiskFileName : filename;VAR Ext : Extension);
  30. (* returns the extension portion of the filename without removing it *)
  31. VAR WherePeriod, ExtLength : CARDINAL;
  32. BEGIN
  33.   WherePeriod := Pos(".", DiskFileName);
  34.   ExtLength := HIGH(DiskFileName) - WherePeriod;
  35.   Copy(DiskFileName, WherePeriod+1, ExtLength, Ext);
  36. END GetExt;
  37.  
  38. END FNAME.
  39.