home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / DATABASE / CAPFIR.ZIP / CAPFIRST.PRG < prev    next >
Text File  |  1993-05-04  |  3KB  |  81 lines

  1. /*
  2.     Function:  CapFirst 
  3.  
  4.     Author:    DAVID -( FLASH )- GORDON
  5.  
  6.     Date:      4 MAY 93
  7.  
  8.     Purpose:   Cleans Up Menus, Error Messages and Warnings, or
  9.                Any Other Text You Need Displayed CapFirst.
  10.  
  11.     Copyright (c) 1993 - FLASHPOINT - ALL RIGHTS RESERVED 
  12.  
  13. NOTE:
  14.  
  15.  -  This Function Came Into Existence For Me When A Large (47K Line) Program
  16.     Had All of Its Source Code Reduced To Lower Case And All Comments Removed.
  17.  
  18.  -  All Network Messages and Text Displayed In Windows Was In Need of Clean Up
  19.     And It Was Eaisier To Add The Function Call Than To Correct The Text.
  20.  
  21.  -  Some Examples of Use Are Below The Source Code Listing.
  22.  
  23.  -  This is all Cliper v5.01 Code
  24. */
  25.  
  26. STATIC FUNCTION CAPFIRST( cOldString )
  27.  
  28.     LOCAL cNewChar := cNewString := "", lCapNext := .t.
  29.  
  30.     IIF( PCOUNT() # 1 .or. VALTYPE( cOldString ) # "C", cOldString := "", )
  31.  
  32. *   cOldString := LOWER( cOldString )
  33.  
  34.     FOR nElement := 1 to LEN( cOldString )
  35.  
  36.         cNewChar := SUBSTR( cOldString, nElement, 1 )
  37.  
  38.         IF cNewChar == " " .or. cNewChar == "-" .or. cNewChar == "."
  39.             cNewString := cNewString + cNewChar
  40.             lCapNext := .t.
  41.         ELSEIF lCapNext
  42.             cNewString := cNewString + UPPER( cNewChar )
  43.             lCapNext := .f.
  44.         ELSE
  45.             cNewString := cNewString + cNewChar
  46.         ENDIF
  47.  
  48.     NEXT nElement
  49.  
  50. RETURN cNewString
  51.  
  52.  
  53. /*
  54.  
  55. Examples and Other Comments
  56.  
  57.     The first character of the string is raised
  58.     Any character in the string following a SPACE, PERIOD, or HYPHEN is raised
  59.     Any text passed raised will remain so unless you activate the LOWER() line
  60.  
  61.     1.  cText := "this is a test of the capfirst function"
  62.         @ 15,20 SAY CAPFIRST( cText )                                         
  63.                                                                          
  64.         or                                                                    
  65.                                                                          
  66.         @ 15,20 SAY CAPFIRST( "this is a test of the capfirst function" )     
  67.                                                                          
  68.         Returns                                                               
  69.                                                                          
  70.         This Is A Test Of The Capfirst Function                               
  71.  
  72.  
  73.     2.  cText := "capt. john hill MD"
  74.  
  75.         Returns
  76.  
  77.         Capt. John Hill MD
  78.  
  79. */
  80.  
  81.