Game Development Community

case sensitive printing

by Bruno · in Torque Game Builder · 08/22/2009 (7:43 pm) · 3 replies

Hi,

I have a function to print strings on my game, i evaluate each character, and then i print the corresponding image from a fontmap.
I need to find if a character is a Upper case or a Lower case.
Right now, i'm doing it like this :

if(%char $= "a" ) $line1[%this_char_count].setImageMap( fontMap,0 );
if(%char $= "b" ) $line1[%this_char_count].setImageMap( fontMap,1 );
if(%char $= "c" ) $line1[%this_char_count].setImageMap( fontMap,2 );
if(%char $= "d" ) $line1[%this_char_count].setImageMap( fontMap,3 );

With this technique, however, Torque is unable to know the diference between "a" and "A".
How can i do this ?

thanks,
Bruno

#1
08/22/2009 (7:51 pm)
There is a function called stricmp that you can use:

if( stricmp( %char, "a" ) == 0 ) { ...blah... }
#2
08/22/2009 (8:51 pm)
William is right, but the solution could also be encapsulated like this:
function isUpperCase(%char)
{
	%capitalized = StrUpr(%char); 			// Converts string to upper case.
	%result = StrCmp(%capitalized, %char);	// Compares two strings case sensitive.

	if (%result == 0)
		return true;
	
	return false;
}

(Note that this is untested code)
#3
08/24/2009 (2:57 pm)
Thanks guys :)
That's exactly what i was looking for