bug in FindString ?

Just starting out? Need help? Post your questions and find answers here.
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

bug in FindString ?

Post 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
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Re: bug in FindString ?

Post 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.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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:
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post 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
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post 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?
kinglestat
Enthusiast
Enthusiast
Posts: 746
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Post by kinglestat »

tried that code snippet alone....and I got your same results
I must have a bugina somewhere

cheers for your help

Terence
Phoenix
Enthusiast
Enthusiast
Posts: 141
Joined: Sun Sep 04, 2005 2:25 am

Post 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....
akee
Enthusiast
Enthusiast
Posts: 498
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Post 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
Post Reply