home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3168 / adjuncts.icn < prev    next >
Encoding:
Text File  |  1991-04-08  |  1.3 KB  |  77 lines

  1. ############################################################################
  2. #
  3. #    Name:     adjuncts.icn
  4. #
  5. #    Title:     adjuncts (adjunct utilities for gettext and idxtext)
  6. #
  7. #    Author:     Richard L. Goerwitz
  8. #
  9. #    Version: 1.2
  10. #
  11. ############################################################################
  12. #  
  13. #  Pretty mundane stuff.  Basename(), Pathname(), Strip(), and a utility
  14. #  for creating index filenames.
  15. #
  16. ############################################################################
  17. #
  18. #  Links: none
  19. #
  20. #  See also: gettext.icn, idxtext,icn
  21. #
  22. ############################################################################
  23.  
  24.  
  25. global _slash, _baselen
  26.  
  27. procedure Basename(s)
  28.  
  29.     # global _slash
  30.     s ? {
  31.     while tab(find(_slash)+1)
  32.     return tab(0)
  33.     }
  34.  
  35. end
  36.  
  37.  
  38. procedure Pathname(s)
  39.  
  40.     # global _slash
  41.     s2 := ""
  42.     s ? {
  43.     while s2 ||:= tab(find(_slash)+1)
  44.     return s2
  45.     }
  46.  
  47. end
  48.  
  49.  
  50. procedure getidxname(FNAME)
  51.  
  52.     #
  53.     # Discard path component.  Cut basename down to a small enough
  54.     # size that the OS will be able to handle addition of the ex-
  55.     # tension ".IDX"
  56.     #
  57.  
  58.     # global _slash, _baselen
  59.     return right(Strip(Basename(FNAME,_slash),'.'), _baselen, "x") || ".IDX"
  60.  
  61. end
  62.  
  63.  
  64. procedure Strip(s,c)
  65.  
  66.     local s2
  67.  
  68.     s2 := ""
  69.     s ? {
  70.     while s2 ||:= tab(upto(c))
  71.     do tab(many(c))
  72.     s2 ||:= tab(0)
  73.     }
  74.     return s2
  75.  
  76. end
  77.