home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / homonlib.zip / CAPITAL.BAS < prev    next >
BASIC Source File  |  1995-04-13  |  1KB  |  35 lines

  1. DEFINT A-Z
  2.  
  3. DECLARE FUNCTION Capitalize$ (orig$)
  4.  
  5. FUNCTION Capitalize$ (orig$)
  6. '****************************************************************************
  7. 'Capitalizes the first letter of each word in a string after first converting
  8. ' the whole thing to lower case.
  9. '****************************************************************************
  10.  
  11. IF orig$ = "" THEN                      'If the original is a null string,
  12.      Capitalize$ = ""                   'return a null string as it can not
  13.      EXIT FUNCTION                      'be capitalized!
  14. END IF
  15.  
  16. new$ = LCASE$(orig$)                    'Don't alter the original in case the
  17.                                         'calling program still needs it!
  18.                                         'And make it all lower case while
  19.                                         'we're at it.
  20.  
  21. MID$(new$, 1, 1) = UCASE$(MID$(new$, 1, 1))  'Capitalize the first character.
  22.  
  23. FOR x = 1 TO (LEN(new$) - 1)            'Go through the string, capitalizing
  24.                                         'anything that follows a space.
  25.      IF MID$(new$, x, 1) = " " THEN
  26.           MID$(new$, (x + 1), 1) = UCASE$(MID$(new$, (x + 1), 1))
  27.      END IF
  28.  
  29. NEXT x
  30.  
  31. Capitalize$ = new$                      'Return the capitalized string.
  32.  
  33. END FUNCTION
  34.  
  35.