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
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
About the author
#2
(Note that this is untested code)
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)
Associate William Lee Sims
Machine Code Games
if( stricmp( %char, "a" ) == 0 ) { ...blah... }