[6.12 LTS - Win x64] FindString() - False Result

Just starting out? Need help? Post your questions and find answers here.
troof
New User
New User
Posts: 2
Joined: Tue Dec 10, 2024 9:47 pm

[6.12 LTS - Win x64] FindString() - False Result

Post by troof »

Code: Select all

txt$ = "what-the-foo"
count = FindString(txt$,"-")
Debug count
Result = 5 [false]

Code: Select all

 txt$ = "Iiiii-like-purebasic"
count = FindString(txt$,"-")
Debug count
Result = 6 [false]

Error seems to be in first string part:

Code: Select all

txt$ = "w-the-foo"
count = FindString(txt$,"-")
Debug count
Result = 2 [true]

Code: Select all

txt$ = "I-like-purebasic"
count = FindString(txt$,"-")
Debug count
Result = 2 [true]

Cheers
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: [6.12 LTS - Win x64] FindString() - False Result

Post by BarryG »

troof wrote: Tue Dec 10, 2024 9:57 pm

Code: Select all

txt$ = "what-the-foo"
count = FindString(txt$,"-")
Debug count
Result = 5 [false]
Why is that false? The first dash is indeed position 5. Not a bug.
troof
New User
New User
Posts: 2
Joined: Tue Dec 10, 2024 9:47 pm

Re: [6.12 LTS - Win x64] FindString() - False Result

Post by troof »

Sorry, I confused CountString with FindString. :D
I have problems to switch between programming in javascript and purebasic.
it's too different - and i'm getting old.
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: [6.12 LTS - Win x64] FindString() - False Result

Post by idle »

troof wrote: Tue Dec 10, 2024 10:10 pm Sorry, I confused CountString with FindString. :D
I have problems to switch between programming in javascript and purebasic.
it's too different - and i'm getting old.
Easy enough to confuse, generally post in questions before bugs as it's often the case of users error than bug.
and opps I just sent a pm for the same reason of getting old! clicked the wrong button! :lol:
Olli
Addict
Addict
Posts: 1266
Joined: Wed May 27, 2020 12:26 pm

Re: [6.12 LTS - Win x64] FindString() - False Result

Post by Olli »

The big difference between javascript and purebasic, it is the speed.
I think you can search a byte code in 100 megabytes in javascript, while you can search a byte code in one gigabyte in purebasic.
This difference can bring some motivation to learn. Here is a clock which details about the time resolution in purebasic.

Code: Select all

Procedure CLK()
 ! RDTSC
 ProcedureReturn
EndProcedure

Debug CLK()
Debuh CLK()
User avatar
SPH
Enthusiast
Enthusiast
Posts: 593
Joined: Tue Jan 04, 2011 6:21 pm

Re: [6.12 LTS - Win x64] FindString() - False Result

Post by SPH »

Olli :

"debuh" = error

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
PBJim
Enthusiast
Enthusiast
Posts: 296
Joined: Fri Jan 19, 2024 11:56 pm

Re: [6.12 LTS - Win x64] FindString() - False Result

Post by PBJim »

Olli wrote: Wed Dec 11, 2024 1:08 am Here is a clock which details about the time resolution in purebasic.

Code: Select all

Procedure CLK()
 ! RDTSC
 ProcedureReturn
EndProcedure

Debug CLK()
Debuh CLK()
I'm interested in how the clock counter is being returned by ProcedureReturn.
normeus
Enthusiast
Enthusiast
Posts: 475
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: [6.12 LTS - Win x64] FindString() - False Result

Post by normeus »

" ! RDTSC" places the result in edx and eax on x86 and for x64 it combines them in one register


"ProcedureReturn", as per the pb manual:

Code: Select all

If no value is specified for ProcedureReturn, the return value will be zero if the compiler uses the C backend and for all processors managed by PureBasic, or the content of the 'eax' register in 32 bits (X86 processors) or 'rax' in 64 bits (X64 processors) if the compiler uses the ASM back-end, (see for more information). 

That's one thing about PB, you really have to read the manual

Norm
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Post Reply