Game Development Community

DOC BUG: $= (string comparison) is case INsensitive...

by Jason Cahill · in Torque Game Builder · 03/30/2005 (9:25 pm) · 0 replies

Related to this thread: http://www.garagegames.com/mg/forums/result.thread.php?qt=27950

This is not what I'd expect at all. Both the scripting documentation on this site and the prose in Kenneth Finney's book says that $= means "strings are identical"... but really, it seems to be comparing with stricmp instead of strcmp. This should be clearly documented. I spent about 20 minutes banging my head against a wall with a piece of code that cared about case and couldn't find my bug.

Workarounds:
//case insensitive compares:
if (%a $= %b) { ... }
 
//case insensitive compares (alternative)
if (!stricmp(%a, %b)) { ... }
 
//case sensitive compares
if (!strcmp(%a, %b)) { ... }