Here is a function in MultiScript that does TitleCase. kind of..
@var $exceptionsArray[] = { "a", "an", "and", "any", "at", "from", "into", "of", "on", "or", "the", "to", };
function TitleCase($name)
{
return _TitleCase($name, " ");
}
function _TitleCase($name , $splitchar)
{
@var $result = "";
@var $parts = StrSplit($name , $splitchar); // space and - will split string
@var $cnt = arrayCount( $parts );
for( $n = 0; $n < $cnt ; $n++ )
{
@var $textPart = $parts[ $n ];
// To Lower
$textPart = StrToLower( $textPart );
if( StrFind( $textPart , "-", 0 ) > 0)
{
// Becuse of recursive bug, $n is is overwriten
$oldN = $n;
$textPart = _TitleCase($textPart , "-");
$n = $oldN;
}
if( arrayFind( $exceptionsArray, $textPart ) == -1)
{
// Uppser case on first
$textPart[0] = StrToUpper( $textPart[0] );
}
if( StrLen( $result ) > 0 )
$result += $splitchar;
$result += $textPart;
}
return $result;
}
@var $newText = TitleCase("ANT-MAN AND THE WASP");
Hmm Found a bug with calling recusrive ( same function calling it self.) variables are overwwitten.. so there is a workaround in the code for that..