"blank" != "blank" ???
by Jeremy Tilton · in Torque Game Builder · 03/12/2005 (11:46 am) · 5 replies
Check it, the following two lines of code immediately follow eachother in script:
$piece.tag="blank";
if($piece.tag == "blank")
{
}
Yet the stuff following the if statment never exectues. Conversely:
echo($piece.tag);
if($piece.tag != "blank")
{
}
also never executes when the tag actually doesn't = "blank". Looking at the console.log it says:
T2D/client/client.cs (195): string always evaluates to 0.
Why is that?
$piece.tag="blank";
if($piece.tag == "blank")
{
}
Yet the stuff following the if statment never exectues. Conversely:
echo($piece.tag);
if($piece.tag != "blank")
{
}
also never executes when the tag actually doesn't = "blank". Looking at the console.log it says:
T2D/client/client.cs (195): string always evaluates to 0.
Why is that?
About the author
#2
03/12/2005 (12:04 pm)
Ohhhh right...kinda like how C++ actually performs == on strings....it is only equal if the same spot in memory. Cool, thanks!
#3
03/12/2005 (12:07 pm)
Just as a follow up, if you are using a string for a switch statement, you actually need to use switch$ there as well.
#4
03/12/2005 (12:40 pm)
Cool, i probably would have not caught that either, thanks again!
#5
Personally, I wouldn't have used the $ in that context since it has a significant meaning with global variables, but we have what we have :-)
Has anyone taken a stab at overloading operators in torquescript? It would be nice to support alternate syntaxes like eq and neq for strings, or === for pointer equality. Unless, of course, they are already in there and I just haven't got to them yet :-)
03/12/2005 (12:48 pm)
The non-equality test is $piece.tag !$= "blank".Personally, I wouldn't have used the $ in that context since it has a significant meaning with global variables, but we have what we have :-)
Has anyone taken a stab at overloading operators in torquescript? It would be nice to support alternate syntaxes like eq and neq for strings, or === for pointer equality. Unless, of course, they are already in there and I just haven't got to them yet :-)
Torque 3D Owner Stephen Zepp