QB64 Phoenix Edition
INSTR bug? - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: INSTR bug? (/showthread.php?tid=1512)



INSTR bug? - GTC - 02-27-2023

Edit: Bah, never mind


RE: INSTR bug? - bplus - 02-27-2023

"Gets confused", "behaving badly" ??? Do you have a code example?

For example what does your version do with this?
Code: (Select All)
s$ = "1, 2, 3, 4, 5, 6"
p = InStr(s$, ", ")
While p
    Print p
    p = InStr(p + 2, s$, ", ")
Wend



RE: INSTR bug? - mnrvovrfc - 02-27-2023

(02-27-2023, 12:48 PM)GTC Wrote: I guess the recommendation will be to upgrade, but does anyone recall INSTR behaving badly?

Before posting here and claiming one of the older, extensively-used functions has a bug, you need to provide example code which proves your point. If you have to use the first integer parameter of INSTR(), which could be left out and then it's assumed to be one, the chance increases of it returning zero for perhaps being put far ahead in the string for the search to be of any consequence. Alternatively there is now _INSTRREV() which searches backward from the end of the string toward the beginning.

If the call to INSTR() in your code has three parameters and the first one is an integer variable you have to watch the value of that variable. It cannot be zero nor negative; I believe Q(uick)BASIC was supposed to return an Illegal Function Call there.


RE: INSTR bug? - GTC - 02-27-2023

... after sleeping on it found an INPUT that should be an INPUT LINE

Getting rusty.