Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Proskrito on Sat 31/05/2003 19:48:53

Title: Put the first character of a string in uppercase
Post by: Proskrito on Sat 31/05/2003 19:48:53
I want to make a function that converts a string unformatted into one in lowercase but the first character in uppercase, like,if the string is:
"lOOk, a TRhEe heAded MonkEy", it would return:
"Look, a three headed monkey".
i thought of putting all in lowercase with "StrToLowerCase",
getting the first character with "StrGetCharAt", putting this character in uppercase and replace the first character with "StrSetCharAt".
BUT the main problem is that StrSetCharAt gets the character that have to replace the other as an integer, so i dont know if there is a way to do it.
Any ideas?

Title: Re:Put the first character of a string in uppercase
Post by: Dorcan on Sat 31/05/2003 23:27:47
function ChangeStrCase(string str){
   char S;
   StrToUpperCase(str);
   S=StrGetCharAt (str,0);
   StrToLowerCase(str);
   StrSetCharAt(str,0,S);
}
Title: Re:Put the first character of a string in uppercase
Post by: Scorpiorus on Sat 31/05/2003 23:55:16
QuoteBUT the main problem is that StrSetCharAt gets the character that have to replace the other as an integer, so i dont know if there is a way to do it.
Don't worry about. You can pass an integer representing a character.

-Cheers