home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / decus / RB125 / basename.pas < prev    next >
Pascal/Delphi Source File  |  1995-06-04  |  3KB  |  153 lines

  1. (***********************************************************************
  2.  
  3. Name:        BaseName.Pas
  4. Version:    1.0
  5.  
  6.      This software has been placed into the public domain by Digital
  7.              Equipment Corporation.
  8.  
  9.  
  10. DISCLAIMER:
  11.  
  12. The information herein is subject to change without  notice  and  should
  13. not be construed as a commitment by Digital Equipment Corporation.
  14.  
  15. Digital Equipment Corporation assumes no responsibility for the  use  or
  16. reliability  of  this  software.   This  software  is  provided "as is,"
  17. without any warranty of any kind, express or implied.  Digital Equipment
  18. Corporation  will  not    be liable in any event for any damages including
  19. any loss of data, profit, or savings, claims against  the  user  by  any
  20. other  party,  or  any other incidental or consequential damages arising
  21. out of the use of, or inability to use, this software, even  if  Digital
  22. Equipment Corporation is advised of the possibility of such damage.
  23.  
  24. DEFECT REPORTING AND SUGGESTIONS:
  25.  
  26. Please send reports of defects or suggestions for  improvement    directly
  27. to the author:
  28.  
  29.     Brian Hetrick
  30.     Digital Equipment Corporation
  31.     110 Spit Brook Road  ZKO1-3/J10
  32.     Nashua NH  03062-2698
  33.  
  34. Do NOT file a Software Performance Report on  this  software,  call  the
  35. Telephone  Support  Center regarding this software, contact your Digital
  36. Field Office  regarding  this  software,  or  use  any    other  mechanism
  37. provided for Digital's supported and warranted software.
  38.  
  39.  
  40. FACILITY:
  41.  
  42.     TURBO Pascal MS-DOS support routines
  43.  
  44. ABSTRACT:
  45.  
  46.     Obtains the last component of a path specification
  47.  
  48. ENVIRONMENT:
  49.  
  50.     MS-DOS V2.0 or later, compiled with  Borland  International's  TURBO
  51.     Pascal V3.0 or later.
  52.  
  53. AUTHOR: Brian Hetrick, CREATION DATE: 2 December 1986.
  54.  
  55. MODIFIED BY:
  56.  
  57.     Brian Hetrick, 02-Dec-86: Version 1.0
  58.   000 - Original creation of module.
  59.  
  60. ***********************************************************************)
  61. {.PA}
  62. (*
  63.  *  INCLUDE FILES:
  64.  *)
  65.  
  66. (*
  67.  *  LABEL DECLARATIONS:
  68.  *)
  69.  
  70. (*
  71.  *  CONSTANT DECLARATIONS:
  72.  *)
  73.  
  74. (*
  75.  *  TYPE DECLARATIONS:
  76.  *)
  77.  
  78. TYPE
  79.  
  80.     BaseNamePath = STRING [255];
  81.  
  82. (*
  83.  *  OWN STORAGE:
  84.  *)
  85.  
  86. (*
  87.  *  TABLE OF CONTENTS:
  88.  *)
  89. {.PA}
  90. FUNCTION BaseName
  91.    (    PathSpec : BaseNamePath) : BaseNamePath;
  92.  
  93. (***********************************************************************
  94.  
  95. FUNCTIONAL DESCRIPTION:
  96.  
  97.     Extracts the last component of a path specification.  The components
  98.     of a path specification are separated by colons  (:),  slashes  (/),
  99.     and back slashes (\).
  100.  
  101. FORMAL PARAMETERS:
  102.  
  103.     Path.mt.r - The path specification from which the base name is to be
  104.     extracted.
  105.  
  106. RETURN VALUE:
  107.  
  108.     The base name of the path specification.
  109.  
  110. IMPLICIT INPUTS:
  111.  
  112.     None.
  113.  
  114. IMPLICIT OUTPUTS:
  115.  
  116.     None.
  117.  
  118. SIDE EFFECTS:
  119.  
  120.     None.
  121.  
  122. ***********************************************************************)
  123.  
  124.     VAR
  125.  
  126.     HoldIndex : INTEGER;
  127.     ScanIndex : INTEGER;
  128.     ThisChar  : CHAR;
  129.  
  130.     BEGIN
  131.  
  132.     HoldIndex := 1;
  133.  
  134.     FOR ScanIndex := 1 TO Length (PathSpec)
  135.     DO
  136.     BEGIN
  137.  
  138.     ThisChar := PathSpec [ScanIndex];
  139.  
  140.     IF (ThisChar = ':') OR
  141.        (ThisChar = '/') OR
  142.        (ThisChar = '\')
  143.     THEN
  144.  
  145.         HoldIndex := ScanIndex + 1
  146.  
  147.     END;
  148.  
  149.     BaseName := Copy (PathSpec, HoldIndex,
  150.     Length (PathSpec) - HoldIndex + 1)
  151.  
  152.     END;
  153.