Skip to content

Instantly share code, notes, and snippets.

@z0w0
Created March 18, 2011 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z0w0/875606 to your computer and use it in GitHub Desktop.
Save z0w0/875606 to your computer and use it in GitHub Desktop.
A TorqueScript function that capitalizes the first letters in each word.
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