INSTR buggy wuggy

Previous topic - Next topic

MrTAToad

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

Moru

Yes very funny, if you insert a space at the start before Spots, it will return -1 as it's supposed to do.

Kitty Hello

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.