Created
March 18, 2011 04:03
-
-
Save z0w0/875606 to your computer and use it in GitHub Desktop.
A TorqueScript function that capitalizes the first letters in each word.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function strCap(%string) | |
{ | |
%c = getWordCount(%string); | |
for(%i=0;%i<%c;%i++) | |
{ | |
%w = getWord(%string,%i); | |
%l = strLen(%w); | |
if(%l > 1) | |
%string = setWord(%string,%i,strUpr(getSubStr(%w,0,1)) @ getSubStr(%w,1,%l-1)); | |
else | |
%string = setWord(%string,%i,strUpr(%w)); | |
} | |
return %string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment