Author Topic: INSTR buggy wuggy  (Read 991 times)

MrTAToad

  • Guest
INSTR buggy wuggy
« 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

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1786
    • View Profile
    • Homepage
Re: INSTR buggy wuggy
« Reply #1 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.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10732
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: INSTR buggy wuggy
« Reply #2 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.