GLBasic forum

Main forum => Bug Reports => Topic started by: MrTAToad on 2011-Jan-05

Title: INSTR buggy wuggy
Post by: MrTAToad on 2011-Jan-05
For some reason, the following :

Code (glbasic) Select
DEBUG INSTR("Spots","SPR_B") 

returns 0  :blink:

The only thing I can think is that INSTR performs character by character comparison which stops as soon as the first character has been correctly compared, instead of comparing whole text
Title: Re: INSTR buggy wuggy
Post by: Moru on 2011-Jan-05
Yes very funny, if you insert a space at the start before Spots, it will return -1 as it's supposed to do.
Title: Re: INSTR buggy wuggy
Post by: Kitty Hello on 2011-Jan-05
I'm so sorry! Must have been horror to find.
When the length of both strings equal, I call a different function, that compares the strings 4 bytes at once (as far as there are more than 4 bytes to compare, left). In that function I use an int32 pointer instead of the char pointer to compare. BUT! I compared the char pointers here (typo I guess).
I fixed it in the next update.