Code archives/Miscellaneous/Function to capitalize the first letter of each word in a string
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This function will accept a case insensitive text string and return the string with the first character in each word capitalized, and the rest of the characters converted to lower-case. | |||||
Function Capitalize$( t$ ) ; This function will accept a case insensitive string ; and return the string with the first character in each word ; capitalized, and the rest of the characters converted to lower-case. t$ = Lower( t$ ) Local l = Len( t$ ) Local c$ = "", r$ = "", old_c$, i For i = 1 To l old_c$ = c$ c$ = Mid( t$, i, 1 ) If ( i = 1 ) Or ( old_c$ = " " ) Then c$ = Upper( c$ ) r$ = r$ + c$ Next Return r$ End Function ; == EXAMPLE CODE == Print Capitalize( "the cat sat on the mat" ) WaitKey : End |
Comments
| ||
Is there a way you can detect capslock, and make it so that if capslock is ON, then it prints out a capital letter to a text file, or if capslocks off, then it prints out a non-capital letter to a text file, and make it so that it can print then together, LiKe THis ? |
Code Archives Forum