Extremely simple IF command driving me nuts.. Help please (SOLVED)

Started by poc301, Fri 05/11/2004 20:05:57

Previous topic - Next topic

poc301

I have been working for 20 minuts on this INCREDIBLY simple code snippet that isn't working...Ã,  Any help would be appreciated :(

CODE:

// script for room: First time player enters screen

string class;

GetGlobalString(17,class) ;Ã,  /This should be the word Warrior

if (class == "Warrior")

{
display ("IT WORKED!");


}

Display("It didn't work... %s", class);


---------------------

Now, the thing doesn't work, as it skips right on through to the bottom line "It didn't work... %s", class line.

When that bottom line is run, it reads :

It didn't work... Warrior

So I know the Global string is being pulled out properly, but for some reason my IF statement isn't working.. ARGH!

I would greatly appreciate any help.

Thanks,

Bill Garrett
Ã, 


Janik

Your comment

GetGlobalString(17,class) ;  /This should be the word Warrior

is missing a slash:

GetGlobalString(17,class) ;  //This should be the word Warrior

Also, you'll want to put an "else" before displaying "it doesn't work".
Play pen and paper D&D? Then try DM Genie - software for Dungeons and Dragons!

poc301

The // thing was done as I was posting it here on the forum.  That comment isn't in the real code.  I just wanted to clarify for anyone looking at it.

I put the 'else' in, and I also made it 'Display'. 

Still having the same problem.  The global variable does have Warrior in it, but the IF statement isn't working :(

Any other ideas?

Thanks,

Bill Garrett

Hellomoto

It might not work, but try looking up strcomp in the manual. I think it has something to do with the fact that strings are not actual variables, but arrays, so you have to use a special function to check if to strings are equal.

In AGS, I think its strcomp, but I might be wrong.

poc301

I resolved my issue with a backwards workaround :)

I created an INT of 1,2,3,4 (one for each class), that I can use to determine which view the EGO will use.

I then did a backwards workaround (if globalblahblah(1) then doohickie= "Warrior") 

So I have everything working great now.

Thanks guys!

Bill Garrett

Proskrito

you can not compare strings with '==', use the functions StrComp or StrCaseComp instead. You can see the details of these functions in the manual. Hope it helps : )

SMF spam blocked by CleanTalk