home *** CD-ROM | disk | FTP | other *** search
- /*
- Program: FIRSTCAP.PRG
- System: GRUMPFISH LIBRARY
- Author: Greg Lief
- Copyright (c) 1988-90, Greg Lief
- Clipper 5.x Version
- Compile instructions: clipper firstcap /n/w/a
- */
- function firstcap(cstring)
- local nlength := len(trim(cstring)), xx
- //----- make first character upper-case and all others lower-case
- cstring := upper(substr(cstring, 1, 1)) + lower(substr(cstring, 2))
- for xx = 2 to nlength - 1
- //----- test for punctuation, space, "mac" or "mc"
- if substr(cstring, xx, 1) $ ". '-/,&*(+\" .or. ;
- (xx > 2 .and. substr(cstring, xx - 2, 3) = "Mac") .or. ;
- substr(cstring, xx - 1, 2) = "Mc"
- cstring := substr(cstring, 1, xx) + upper(substr(cstring, xx + 1, 1)) + ;
- substr(cstring, xx + 2)
- endif
- next
- return cstring
-
- * end function FirstCap()
- *--------------------------------------------------------------------*
-
- * eof firstcap.prg
-