PureBasic 6.40 alpha 3 is ready, surprise inside !

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
HeX0R
Addict
Addict
Posts: 1242
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: PureBasic 6.40 alpha 1 is ready, surprise inside !

Post by HeX0R »

diceman wrote: Tue Jan 27, 2026 8:56 pm
Fred wrote: Fri Jan 23, 2026 10:47 amBasically if you patch a string by putting a zero in it, the Len() function will be wrong, and the concat functions will fail. You will need to use PeekS() for this.
Please, for really stupid people like me, can you explain in layman's terms what that actually means? :o

Code: Select all

a$ = "1234567890"
PokeU(@a$ + 5 * SizeOf(CHARACTER), 0) ;write an end of string after the "5" to shorten the string by "cheating"/patching
Debug Len(a$)	;PB <6.40 will show 5, ;PB 6.40 will still show 10, because it doesn't care about the end of string character
   ;solution for PB6.40 here would be:
   ;a$ = PeekS(@a$) ;just uncomment it and see the difference
   ;because PeekS() looks for the first zero byte/word and the strings size will be corrected
a$ + "67890" ;concat
Debug a$ ;PB <6.40 will show 1234567890, PB 6.40 will show 12345, because in PB 6.40 the string is now in memory "12345" + chr(0) + "7890" + "67890" (+ chr(0))
ShowMemoryViewer(@a$, 32)
Debug Len(a$) ;PB <6.40 shows 10, PB 6.40 shows 15
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PureBasic 6.40 alpha 1 is ready, surprise inside !

Post by ChrisR »

freak wrote: Tue Jan 27, 2026 7:50 pm Just don't act surprised when that code breaks in the future because you are clearly messing with internals here. There is such a thing as over-optimizing.
Thanks Freak, for warning me about the risk for future versions!
mk-soft wrote: Tue Jan 27, 2026 8:20 pm The test on NIL (null pointer) is missing
Yep (If *s <> 0), but to know that it's the same with PeekS() :
Define PureBasicPath$ : PureBasicPath$ = PeekS(@PureBasicPath$)

It might be good to have a native function to reset the string size (with null pointer test) and without the return string, instead of PeekS
User avatar
HeX0R
Addict
Addict
Posts: 1242
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: PureBasic 6.40 alpha 1 is ready, surprise inside !

Post by HeX0R »

ChrisR wrote: Tue Jan 27, 2026 11:36 pm It might be good to have a native function to reset the string size (with null pointer test), instead of PeekS and without the return string
I'm fine with the native command PeekS().
And frankly speaking, you shouldn't take freaks comment too serious.
I mean, where else would you store the length of the string or what else would you like to store internally in a string in future?
Tinkering with internals always carries a risk to break in future, no question, but here I have no idea which upcoming feature might break this.
From my point of view, the code from fryquez is pretty future proof.
Although I never will need it most likely, those rare cases I might discover are fixed with a simple PeekS().
(and I need no speedtest to decide this 😁)

btw.:
Yep (If *s <> 0), but to know that it's the same with PeekS() :
It's not the same, there is a quite huge difference between a Compiler Error and an IMA
User avatar
ChrisR
Addict
Addict
Posts: 1576
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PureBasic 6.40 alpha 1 is ready, surprise inside !

Post by ChrisR »

Hi HeX0R, I agree with almost everything you wrote.
I also have no idea what functionality changes could cause problems in the future but I'm polite and Freak deserves respect.
More than the speed, which is pin-up, I was mainly interested in the procedure ingenuity.
Otherwise, I would have preferred a native function without any return value. But anyway, I won't be using it often too, and PeekS or ResetStringLength() does the job.
In future, I wouldn't be surprised to see a few bugs here and there due to forgetting to use PeekS() to recalculate the right size.
Also you're right about Compiler Error vs IMA
Fred
Administrator
Administrator
Posts: 18498
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by Fred »

2026-01-28: alpha 2 is available for Windows x64, with all known bug fixed. Thanks to all for the early testing !
threedslider
Enthusiast
Enthusiast
Posts: 578
Joined: Sat Feb 12, 2022 7:15 pm

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by threedslider »

Again ! Thanks a lot to all Team and Fred :D

I will test it !
Fred
Administrator
Administrator
Posts: 18498
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by Fred »

I just uploaded a new version because the IDE wasn't build on the correct branch.
threedslider
Enthusiast
Enthusiast
Posts: 578
Joined: Sat Feb 12, 2022 7:15 pm

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by threedslider »

@Fred : I have just tested the new beta 2, it says me an error from PB at launching :

Image

Fred wrote: Wed Jan 28, 2026 4:51 pm I just uploaded a new version because the IDE wasn't build on the correct branch.
Ok I will test it :shock:
threedslider
Enthusiast
Enthusiast
Posts: 578
Joined: Sat Feb 12, 2022 7:15 pm

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by threedslider »

@Fred : Ok it is fixed now ! :shock:

T'es super talentueux ! Merci pour ta rapidité et ta creativité tu nous inspire beaucoup ! :mrgreen:
mbierly
New User
New User
Posts: 4
Joined: Thu Jan 18, 2024 1:21 am
Location: Pennsylvania, US

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by mbierly »

Thanks to Fred and the Team for the superior engineering!

It amazes me how they produce old-school efficient code. Reworking the string handling from the ground up and it only added 129K to a debug version of an app I'm working on! I'm used to Delphi where a new release would add MB's of size to the exe when recompiling the same code.

PureBasic is truly a a gem! Thanks again for producing such a great tool!
Sergey
User
User
Posts: 82
Joined: Wed Jan 12, 2022 2:41 pm

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by Sergey »

mbierly wrote: Thu Jan 29, 2026 1:54 am ... Reworking the string handling from the ground up and it only added 129K to a debug version of an app I'm working on!
FAsm: Ha, hold my beer, the entire assembly compiler file size just 121 KB :D
freak
PureBasic Team
PureBasic Team
Posts: 5959
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: PureBasic 6.40 alpha 1 is ready, surprise inside !

Post by freak »

HeX0R wrote: Wed Jan 28, 2026 12:00 amAnd frankly speaking, you shouldn't take freaks comment too serious.
I mean, where else would you store the length of the string or what else would you like to store internally in a string in future?
Tinkering with internals always carries a risk to break in future, no question, but here I have no idea which upcoming feature might break this.
From my point of view, the code from fryquez is pretty future proof.
How about encoding more information in some bits of the value like it is done right now with the temporary bit? It would not be unheard of.

The problem is spreading this code as a "tip" around the forum, which will lead to people blindly using it thinking they are doing a clever optimization without understanding the details. And then if we do change something, we have to deal with the complaints again. And all that for an "optimization" that is not even worth that word.
quidquid Latine dictum sit altum videtur
User avatar
mk-soft
Always Here
Always Here
Posts: 6529
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by mk-soft »

Attention!

Just noticed while testing my module ActiveScript.

That's no longer possible with interfaces with the new string manager ...

Code: Select all

  Procedure GetItemInfo(*this.objActiveScriptSite, SpaceName.s, ReturnMask.l, *ItemPtr.Integer, *TypeInfo.Long)
    Protected name.s
    
    Debug "ActiveScriptSite - GetItemInfo() : SpaceName = " + SpaceName, #DebugLevelActiveScript
    Select ReturnMask
      Case #SCRIPTINFO_IUNKNOWN
        name = LCase(SpaceName)
It must be fetched with PeekS the SpaceName ...

Code: Select all

  Procedure GetItemInfo(*this.objActiveScriptSite, pstrName, ReturnMask.l, *ItemPtr.Integer, *TypeInfo.Long)
    Protected name.s
    
    Debug "ActiveScriptSite - GetItemInfo() : SpaceName = " + PeekS(pstrName), #DebugLevelActiveScript
    Select ReturnMask
      Case #SCRIPTINFO_IUNKNOWN
        name = LCase(PeekS(pstrName))
 
The same applies to all API CallBack with string handover.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
DayDreamer
User
User
Posts: 33
Joined: Thu Aug 03, 2023 5:44 pm
Location: Off Planet

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by DayDreamer »

Absolutely great about new improvements.

I've installed the 6.40 MacOS beta 2 on an M1 MacBook Air to replace previous version of PureBasic. After install the IDE "About PureBasic" shows PureBasic 6.30 beta 7? So, when I then "Check for upgrades" I get prompt that an update is still available even though I've downloaded and installed the latest. This appears to be a bug. Any explanation much appreciated. Thank you.
User avatar
Kiffi
Addict
Addict
Posts: 1520
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: PureBasic 6.40 alpha 2 is ready, surprise inside !

Post by Kiffi »

DayDreamer wrote: Fri Jan 30, 2026 1:04 amAny explanation much appreciated.
Fred wrote: Fri Jan 23, 2026 10:47 am2026-01-28: alpha 2 is available for Windows x64
We have to wait a little longer. :wink:
Hygge
Post Reply