home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / FIRSTCAP.PRG < prev    next >
Encoding:
Text File  |  1991-04-23  |  928 b   |  28 lines

  1. /*
  2.    Program: FIRSTCAP.PRG
  3.    System:  GRUMPFISH LIBRARY
  4.    Author:  Greg Lief
  5.    Copyright (c) 1988-90, Greg Lief
  6.    Clipper 5.x Version
  7.    Compile instructions: clipper firstcap /n/w/a
  8. */
  9. function firstcap(cstring)
  10. local nlength := len(trim(cstring)), xx
  11. //----- make first character upper-case and all others lower-case
  12. cstring := upper(substr(cstring, 1, 1)) + lower(substr(cstring, 2))
  13. for xx = 2 to nlength - 1
  14.    //----- test for punctuation, space, "mac" or "mc"
  15.    if substr(cstring, xx, 1) $ ". '-/,&*(+\" .or. ;
  16.          (xx > 2 .and. substr(cstring, xx - 2, 3) = "Mac") .or. ;
  17.          substr(cstring, xx - 1, 2) = "Mc"
  18.       cstring := substr(cstring, 1, xx) + upper(substr(cstring, xx + 1, 1)) + ;
  19.                  substr(cstring, xx + 2)
  20.    endif
  21. next
  22. return cstring
  23.  
  24. * end function FirstCap()
  25. *--------------------------------------------------------------------*
  26.  
  27. * eof firstcap.prg
  28.