Possible bug?
Displaying 1-12 of 12 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
torin

Apologies if this has been posted before (the forum could
use a search functiion!). The following code doesn't compile
(gives error "Could not resolve identifier _script"):


int _FindUnusedIID()
{
int iid;
for(iid = 0; iid < MAX_TOTAL_INVOKES; iid++) {
if(_script[iid] == "") {
return iid;
}
}
return 0 - 1;
}


The following code does:


int _FindUnusedIID()
{
int iid;
for(iid = 0; iid < MAX_TOTAL_INVOKES; iid++) {
if(len(_script[iid]) == 0) {
return iid;
}
}
return 0 - 1;
}


_script is declared as a global array of strings. Anyone else seen this before?

-- torin

Posted on 2004-07-15 03:17:28

torin

Also, if I change _script to an array of integers and "" to a number, it works.

Posted on 2004-07-15 03:18:28

mcgrue

string comparison cannot be done via ==. You want

int strcmp(string a, string b)

because I dislike the semantics of that function, I always use my own wrapper around it,as follows:


/**
* A simple case-insensitive string comparison.
*
* Returns true if the two strings are the same.
*/
int equ( string a, string b ) {
if( !strcmp(toUpper(a),toUpper(b)) ) {
return 1;
} else {
return 0;
}
}

Posted on 2004-07-15 03:25:30

Omni

Strcmp returns 0 on identical strings.

if (!strcmp("dog", "dog")) { do stuff; }

Posted on 2004-07-15 03:29:13

torin


It *would* be something like that. I looked at the string docs before I posted too. That's what I get for coding in Python for three nights straight.

Thanks, grue.



Posted on 2004-07-15 03:32:00

blues_zodiakos

Ooh, McGrue, I like that wrapper function! So much, I think I'll steal it. -- Zaphod Beeblebrox

Posted on 2004-07-15 04:28:21

mcgrue

It's used prominantly in the Sully code.

...

...speaking of, I should finish that ^_^

Posted on 2004-07-15 04:47:49

vecna

I use a streq() function internally a lot as well.

The strcmp() notation does have a logic tho, you can use it for sorting, which you can't do with a streq() type notation.

Posted on 2004-07-15 05:09:40

mcgrue

Quote:Originally posted by torin


What would you call the machine that god used to create the universe?


A Commodore 64.

I have all the answers tonight.

Posted on 2004-07-15 05:53:38

Interference22

Quote:Originally posted by Blues Zodiakos

Ooh, McGrue, I like that wrapper function! So much, I think I'll steal it. -- Zaphod Beeblebrox


"We liked it so much, we bought the Galaxy."

Posted on 2004-07-16 00:17:20

Zip

Quote:Originally posted by mcgrue

...because I dislike the semantics of that function, I always use my own wrapper around it


All that just for !strcmp() ... seems a little unnessersary. :D

Zip

Posted on 2004-07-20 16:23:47

mcgrue

Quote:Originally posted by Zip

Quote:Originally posted by mcgrue

...because I dislike the semantics of that function, I always use my own wrapper around it


All that just for !strcmp() ... seems a little unnessersary. :D

Zip


for some reason, I don't find !strcmp() to be very readable. Also, my equ() is a case-insensitive string equality checker... expanded it'd be:


if( !strcmp( ToUpper(string1), ToUpper(string2) ) ) {
//do the stuff
}


And that much code I have no qualms about encapsulating.

Posted on 2004-07-21 13:12:01


Displaying 1-12 of 12 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.