Page 1 of 1

bug in FindString ?

Posted: Sun Jul 30, 2006 10:34 am
by kinglestat
Gentlefolks,

I was debugging a smple sql parser, and got stuck with this line

Pos = FindString ( q$, "<rnd", 1 )
look = Pos + 3
q$ = "SELECT list.data FROM list where ( list.index = <rnd=100> )"
start = FindString ( q$, "=", look )

FindString keeps returning a position on the first "="
Is this a bug ? Or it is my mistake ?

thanks

Terence

Re: bug in FindString ?

Posted: Sun Jul 30, 2006 10:41 am
by Pupil
kinglestat wrote:Gentlefolks,

I was debugging a smple sql parser, and got stuck with this line

Pos = FindString ( q$, "<rnd", 1 )
look = Pos + 3
q$ = "SELECT list.data FROM list where ( list.index = <rnd=100> )"
start = FindString ( q$, "=", look )

FindString keeps returning a position on the first "="
Is this a bug ? Or it is my mistake ?

thanks

Terence
I can't quite follow your code, what's in q$ when you do the first 'FindString()'?
If q$ is empty => 'Pos = 0' => 'look = 3' => start points to first '='-character encountered.

Posted: Sun Jul 30, 2006 10:44 am
by Trond

Code: Select all

q$ = "SELECT list.data FROM list where ( list.index = <rnd=100> )"
Pos = FindString ( q$, "<rnd", 1 )
look = Pos + 3
start = FindString ( q$, "=", look ) 
:wink:

Posted: Sun Jul 30, 2006 12:05 pm
by kinglestat
code reads

q$ = "SELECT list.data FROM list where ( list.index = <rnd=100> )"

Pos = FindString ( q$, "<rnd", 1 )
look = Pos + 3
start = FindString ( q$, "=", look )

start is 47 but should be 53

Posted: Sun Jul 30, 2006 12:34 pm
by Pupil
kinglestat wrote:code reads

q$ = "SELECT list.data FROM list where ( list.index = <rnd=100> )"

Pos = FindString ( q$, "<rnd", 1 )
look = Pos + 3
start = FindString ( q$, "=", look )

start is 47 but should be 53
with the code as written above i get:
Pos = 49
look = 52
start = 53

mind you i'm still using PB3.94 so maybe someone with PB4.0 could check also?

Posted: Sun Jul 30, 2006 12:42 pm
by kinglestat
tried that code snippet alone....and I got your same results
I must have a bugina somewhere

cheers for your help

Terence

Posted: Sun Jul 30, 2006 12:55 pm
by Phoenix
kinglestat wrote:code reads

q$ = "SELECT list.data FROM list where ( list.index = <rnd=100> )"

Pos = FindString ( q$, "<rnd", 1 )
look = Pos + 3
start = FindString ( q$, "=", look )

start is 47 but should be 53
start is 53 here with both PureBasic versions 3.94 and 4....

Posted: Tue Aug 01, 2006 7:58 am
by akee
The results are correct. No bugs.

Code: Select all

;              1         2         3         4         5         6
;     123456789012345678901234567890123456789012345678901234567890
q$ = "SELECT list.data FROM list where ( list.index = <rnd=100> )" 

Pos = FindString ( q$, "<rnd", 1) 
look = Pos + 3 
start = FindString ( q$, "=", look ) 

Debug Pos     ; 49
Debug look    ; 52
Debug start   ; 53