Game Development Community

Comparing Strings - Is My Logic Incorrect? - RESOLVED

by Randy Lutcavich · in Torque Game Builder · 06/09/2009 (12:12 am) · 2 replies

Say you have:

%testString = "test";

if(%testString == "wrong")
{
echo("This should never be seen");
echo(%testString);
}

For some reason when I use this kind of logic in my script, the echo calls will always occur. Why would it even enter the if statement if the condition statement doesn't evaluate to true??

Is this a really stupid question? Am I that tired? Or is there something I should know about torquescript?

#1
06/09/2009 (1:05 am)
To compare strings you need to use "$=", try this
if(%testString $= "wrong")
{
   echo("This should never be seen");
   echo(%testString);
}

"==" are used to compare numbers :D
#2
06/09/2009 (1:07 am)
Wow! Glad it was something simple that I was doing wrong. That was driving me crazy! haha

Thanks Aun!