Need a working example of "string.equals_ignore_case(st

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jerrelDulay
Posts: 15
Joined: Tue Nov 02, 2010 4:49 am

Need a working example of "string.equals_ignore_case(st

Post by jerrelDulay »

Hiya guys! I'm pulling my hair out over this one. I've tried rearranging and changing this bit of code about three dozen times, changing the check cases, but it never seems to trigger. I need to check a node's name to see if it matches "terrain", but I can't get it to work. I've scoured the internet for an example but couldn't find out.

Code: Select all

core::stringw nodename = node->getName();
	core::stringw nodecheck = "terrain";
	if (nodename.equals_ignore_case(nodecheck) )       //<- this isn't working :/
		terrainNode = (scene::ITerrainSceneNode*) node;
I'd super appreciate a working example of how to properly use "equals_ignore_case". Or if this is even the wrong function to use to check string values, I would also appreciate a point in the right direction.

Thanks guys!
=D
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Post by REDDemon »

if this is really the code for what you need equals_ignore_case i suggest you to use the operator == instead.

so

Code: Select all

core::stringw A=L"Terrain";
core::stringw B=L"Terrain";

if (A==B)
return true;
with equals_ignore_case

Code: Select all

core::stringw A="TerRAiN";
core::stringw B="TERRAIN";
core::stringw C="terrain";

A.equals_ignore_case (B); //return true
B.equals_ignore_case(C); //return true;
ecc.

the strings are checked and case is ignored. so they are equals also if one has some upper case char and the other one not.

so your code

Code: Select all

core::stringw nodename = node->getName();
   core::stringw nodecheck = "terrain";
   if (nodename.equals_ignore_case(nodecheck) )       //<- this isn't working :/
      terrainNode = (scene::ITerrainSceneNode*) node;

   
is working. probably you need to check "nodename" and probably you will see that its value is not "terrain"(or "TERRAIN" or "terrAIN" ecc).
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
jerrelDulay
Posts: 15
Joined: Tue Nov 02, 2010 4:49 am

Post by jerrelDulay »

Thanks a lot, mate! It's workin' now. With your help, I came to the realization I wasn't putting the value of "name" in the right place in the *.irr scene file I was using. I added the name after the file was created.

Code: Select all

<node type="terrain">

		<attributes>
			<string name="Name" value="terrain" />
The problem was that I was putting the value 'terrain' in the string 'name' spot instead of the 'value' position. Cheers mate! Now all that's left is to buy my tizanidine medication online - no prescription.
Post Reply