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
bug in FindString ?
-
- Enthusiast
- Posts: 746
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
Re: bug in FindString ?
I can't quite follow your code, what's in q$ when you do the first 'FindString()'?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
If q$ is empty => 'Pos = 0' => 'look = 3' => start points to first '='-character encountered.
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 )

-
- Enthusiast
- Posts: 746
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
with the code as written above i get: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
Pos = 49
look = 52
start = 53
mind you i'm still using PB3.94 so maybe someone with PB4.0 could check also?
-
- Enthusiast
- Posts: 746
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
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