Page 1 of 1
[Done] PureBasic 6.40 alpha 1 Open Save File
Posted: Fri Jan 23, 2026 10:47 pm
by ChrisR
The IDE include in PB 6.40 alpha 1 (windows x64) crashes on Open or Save File
Re: PureBasic 6.40 alpha 1 Open Save File
Posted: Mon Jan 26, 2026 11:42 am
by ChrisR
I don't know if it can helps, but my application compiled with 6.40a1 also crashes on Open(Save)FileRequester, with OnErrorCall, I have:
Error Message: Unknown error code
Source Code File\Line = ProcedureReturn Result (#PB_ProcessPureBasicEvents) in my WinCallback
However, I tried to reproduce it with a simple code using SetWindowCallback() and OpenFileRequester() behind a button, but I cannot reproduce it here!
The rest, generating code with a lot of large string manipulation, seems to work well.
By adding a loop to the code generation to measure speed with a large interface, I go from 9 ms to 7 ms.
Knowing that most concatenations are done using
ExString, but a 2 ms gain is always welcome, congrat

Re: PureBasic 6.40 alpha 1 Open Save File
Posted: Mon Jan 26, 2026 2:35 pm
by Fred
Could you give me the ErrorCode() value you get when using OpenFileRequester() ?
Re: PureBasic 6.40 alpha 1 Open Save File
Posted: Mon Jan 26, 2026 3:03 pm
by ChrisR
Code: Select all
Windows: 11 x64
IceDesign Version: 2.4.2
Source Code File: ObjectTheme.pbi
Source Code Line: 1245 (ProcedureReturn Result (#PB_ProcessPureBasicEvents) in ObjectTheme WinCallback)
Error Code: -529697949
Error Message: Unknown error code
Re: PureBasic 6.40 alpha 1 Open Save File
Posted: Mon Jan 26, 2026 3:30 pm
by fryquez
With PB 6.40 you need to fix all strings modified by API or manual character length changes.
Code: Select all
CompilerIf #PB_Compiler_Version >= 640
Procedure ResetStringLength(*s.Character)
Protected *p.Integer = *s -SizeOf(Integer)
*p\i = 0
While *s\c
*p\i + 1
*s + SizeOf(Character)
Wend
EndProcedure
CompilerElse
Macro ResetStringLength(s)
;
EndMacro
CompilerEndIf
In your WinCallback() there you have GetClassName_() call
Code: Select all
Buffer = Space(64)
IF GetClassName_(ParentGadget, @Buffer, 64)
ResetStringLength(@Buffer)
Re: PureBasic 6.40 alpha 1 Open Save File
Posted: Mon Jan 26, 2026 4:23 pm
by ChrisR
Oh! yes, thanks a lot fryquez and glad to see you around my friend
Well, I couldn't test it right away, I have lots of other space() and strings modified by API elsewhere to correct too.
But that's the right track, indeed, I didn't think beyond the end of my nose.
And thanks also for the ResetStringLength() macro/procedure.
So, there must be something similar in the IDE as well!
Re: PureBasic 6.40 alpha 1 Open Save File
Posted: Mon Jan 26, 2026 4:42 pm
by Fred
Thanks for the error code, should be fixed for the next alpha
Re: [Done] PureBasic 6.40 alpha 1 Open Save File
Posted: Wed Jan 28, 2026 12:47 pm
by ChrisR
It looks good for the IDE and my app with PB 6.40 alpha2, thanks

Re: [Done] PureBasic 6.40 alpha 1 Open Save File
Posted: Wed Jan 28, 2026 1:59 pm
by Fred
Nice !
Re: [Done] PureBasic 6.40 alpha 1 Open Save File
Posted: Fri Jan 30, 2026 12:12 am
by idle
most of the windows API functions if not all that set a string length either return the length or set a variable with the length
so you could poke the length without having to parse the string.
Code: Select all
PureBasicPath$ = Space(#MAX_PATH)
len = GetModuleFileName_(GetModuleHandle_(#Null$), @PureBasicPath$, #MAX_PATH)
If Len > 0
Debug PeekL(@PureBasicPath$-8)
PokeI(@PureBasicPath$-8,len)
Debug Len(PureBasicPath$)
Debug PureBasicPath$
EndIf
Whether this would be safe depends If Fred uses any of the MSB for flags on the length variable but that would limit strings to 1gb on x86 unless the structure on x86 was extended with a quad for length.
I'll wait and see!
Re: [Done] PureBasic 6.40 alpha 1 Open Save File
Posted: Fri Jan 30, 2026 2:59 am
by ChrisR
Yep, -SizeOf(Integer), I'll wait and see too!
See also, ReplaceCharNewLen()
here, without API. Without resetting the len in the loop, PeeKS() must then be called after the procedure, with a second loops then.
Any procedures on string with a loop per character that modify the final length will be in the same situation, with the length managed internally in the loop or using PeeKS afterward.