Page 4 of 23
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 10:43 am
by the.weavster
useful wrote: Sat Dec 23, 2023 9:39 am
Can someone explain for what purpose the new WebViewGadget gadget appeared, and not the functionality of the existing WebGadget was expanded?
WebGadget has been upgraded:
Added: WebGadget based on Edge component with the #PB_Web_Edge constant (Windows only)
WebViewGadget enables exposing PB functions to JS
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 10:45 am
by the.weavster
Kiffi wrote: Fri Dec 22, 2023 7:31 pm
Fred wrote: Fri Dec 22, 2023 6:14 pm
Code: Select all
...
WebViewGadget(0, 0, 0, 400, 400)
SetGadgetText(0, Html$)
...
In my opinion, the SetGadgetText() command has been mixed up here(?):
SetGadgetText() -> change the current URL.
SetGadgetItemText() -> Change the html code in the gadget with #PB_Web_HtmlCode as 'Item'.
+1
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 10:50 am
by Marc56us
Code: Select all
Added: SvgVectorOutput() for all OS
Added: PdfVectorOutput() for all OS
Hi Fred and Team,
For years I'd been waiting for these functions without daring to hope.
Thank you!
So I pressed the yellow and blue button on login and sent some funds to the team.
(Sorry, Paypals is in $, it's not make a round number in €)

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 11:24 am
by BarryG
the.weavster wrote: Sat Dec 23, 2023 10:43 amWebViewGadget enables exposing PB functions to JS
What does that mean compared to the WebGadget? This is all so confusing now.
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 11:31 am
by useful
the.weavster wrote: Sat Dec 23, 2023 10:43 am
useful wrote: Sat Dec 23, 2023 9:39 am
Can someone explain for what purpose the new WebViewGadget gadget appeared, and not the functionality of the existing WebGadget was expanded?
WebGadget has been upgraded:
Added: WebGadget based on Edge component with the #PB_Web_Edge constant (Windows only)
WebViewGadget enables exposing PB functions to JS
I understood that. I was just expecting an extension of the webgadget functionality through additional parameters and flags (for example #PB_WEB_VIEW / #PB_Web_Edge), not a new gadget.
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 11:35 am
by Marc56us
BarryG wrote: Sat Dec 23, 2023 11:24 am
What does that mean compared to the WebGadget? This is all so confusing now.
From what I understand (we've been talking about it for months), the
WebViewGadget no longer uses the old IE4 component used by
WebGadget, but the Edge (Chrominium) engine. So a lot of incompatible sites will become usable.
The WebViewGadget call
Microsoft Edge WebView2 when run.

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 11:49 am
by Axolotl
Thank you Fred and Fr34k for this wonderful christmas gift....
I hope you get lots of presents back.
Sometimes you just have to be a little patient and everything will be fine.
I wish the whole community a Merry Christmas
Happy coding and stay healthy.
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 12:17 pm
by the.weavster
Marc56us wrote: Sat Dec 23, 2023 11:35 am
BarryG wrote: Sat Dec 23, 2023 11:24 am
What does that mean compared to the WebGadget? This is all so confusing now.
From what I understand (we've been talking about it for months), the
WebViewGadget no longer uses the old IE4 component used by
WebGadget, but the Edge (Chrominium) engine. So a lot of incompatible sites will become usable.
The WebViewGadget call
Microsoft Edge WebView2 when run.
WebGadget can also use Edge now.
WebGadget is for displaying web pages.
WebViewGadget will enable you to create your app's UI using HTML/CSS/JS without the need of a server process.
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 1:08 pm
by HanPBF
Anybody checked #PB_EventType_ColumnClick?
I can not find it in 6.10b1.
EventType() gives 8, I guess for click in header
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 1:15 pm
by pamen
@Fred:
Something is off / different with the handling of pointers as return values of a function.
Assume a list contains structure SomeStructure, we want to find an element by its id.
This works in 6.0 fine, but in 6.1 beta the return value of the function is not a pointer to a structure anymore - it is just a number.
Code: Select all
; get pointer to a found .SomeStructure in the List RulesList
; first Iterate RulesList() - it will find correct pointer and should return the address of the structure:
Procedure.l FindRule(RuleID, List RulesList.SomeStructure())
Protected rulptr.l
ForEach RulesList()
If RulesList()\RuleID = RuleID
rulptr = @RulesList()
Break
EndIf
Next
ProcedureReturn rulptr ; there is an address, if found, seems legit.
EndProcedure
; call the above in the next line - works in PB 6.04 and earlier, crashes in 6.1, as the *rule is just a number, not a pointer anymore:
Protected *rule.SomeStructure = FindRule(ruleid.i, RulesList())
if *rule ; positive address?
; crash here, *rule is not a structure anymore in 6.1, as it was in 6.0
endif
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 1:16 pm
by AZJIO
Lebostein wrote: Sat Dec 23, 2023 9:23 am
Without Doc its hard to find out how all this new stuff works. Most of the new constants (for example #PB_EventType_ColumnClick, #PB_Cipher_HMAC, #PB_Preference_NoBOM ...) seems not available here on Mac OS...
Code: Select all
CreatePreferences(Filename$, #PB_Preference_NoBOM)
Select EventType()
Case #PB_EventType_ColumnClick
Debug "ColumnClick"
EndSelect
Fingerprint(*Buffer , Size , #PB_Cipher_HMAC, Bits)
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 2:18 pm
by NicTheQuick
the.weavster wrote: Fri Dec 22, 2023 7:26 pm
Your WebViewGadget demo above on MX Linux ...
I'm getting Invalid Memory Access on the line:
Code: Select all
BindWebViewCallback(0, "increment", @IncrementJS())
I seem to have all the dependencies listed in the INSTALL script. ( I also have my own wrapper for WebView compiled as libwebview.so on the same PC and that works so I don't think it's a missing dependency ).
I am getting the same error on Ubuntu 22.04.3. Is there something that I am missing?
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 2:27 pm
by User_Russian
pamen wrote: Sat Dec 23, 2023 1:15 pmAssume a list contains structure SomeStructure, we want to find an element by its id.
This works in 6.0 fine, but in 6.1 beta the return value of the function is not a pointer to a structure anymore - it is just a number.
Works without problems.
Code: Select all
Structure SomeStructure
RuleID.i
EndStructure
NewList RulesList.SomeStructure()
AddElement(RulesList())
RulesList()\RuleID = 10
; get pointer to a found .SomeStructure in the List RulesList
; first Iterate RulesList() - it will find correct pointer and should return the address of the structure:
Procedure FindRule(RuleID, List RulesList.SomeStructure())
Protected *rulptr.SomeStructure
ForEach RulesList()
If RulesList()\RuleID = RuleID
*rulptr = @RulesList()
Break
EndIf
Next
ProcedureReturn *rulptr ; there is an address, if found, seems legit.
EndProcedure
; call the above in the next line - works in PB 6.04 and earlier, crashes in 6.1, as the *rule is just a number, not a pointer anymore:
*rule.SomeStructure = FindRule(10, RulesList())
If *rule ; positive address?
Debug *rule\RuleID
; crash here, *rule is not a structure anymore in 6.1, as it was in 6.0
EndIf
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 2:38 pm
by freak
Some examples:
CustomSortList()
Code: Select all
Structure CustomStruct
Value$
EndStructure
; Procedure must take two pointer values as parameter and return:
; #PB_Sort_Lesser if first < second
; #PB_Sort_Greater first > second
; #PB_Sort_Equal if first = second
;
; The functions are intended to sort structured lists, but you can use it on atomic types too by using
; the predefined structures like "Long" or "Integer" for the parameter types
;
Procedure CustomCompare(*a.CustomStruct, *b.CustomStruct)
; Sort by numeric value in the string
If Val(*a\Value$) < Val(*b\Value$)
ProcedureReturn #PB_Sort_Lesser
ElseIf Val(*a\Value$) > Val(*b\Value$)
ProcedureReturn #PB_Sort_Greater
Else
ProcedureReturn #PB_Sort_Equal
EndIf
EndProcedure
NewList Test.CustomStruct()
AddElement(Test()) : Test()\Value$ = "0005"
AddElement(Test()) : Test()\Value$ = "2"
AddElement(Test()) : Test()\Value$ = "42"
AddElement(Test()) : Test()\Value$ = "7"
AddElement(Test()) : Test()\Value$ = "23"
AddElement(Test()) : Test()\Value$ = "100"
AddElement(Test()) : Test()\Value$ = "101"
CustomSortList(Test(), @CustomCompare(), #PB_Sort_Ascending)
ForEach Test()
Debug Test()\Value$
Next
CreatePasswordHash() / VerifyPasswordHash()
Code: Select all
; Create a hash value from a password for storage
Hash$ = CreatePasswordHash("secret")
Debug Hash$
; Multiple calls with the same password result in a different hash due to the use of a random salt
; So do not compare the hashes to check if a password is correct
Debug CreatePasswordHash("secret")
; Instead, VerifyPasswordHash() must be used to check a password
Debug VerifyPasswordHash("secret", Hash$) ; correct
Debug VerifyPasswordHash("secret2", Hash$) ; incorrect
; The optional "WorkFactor" parameter can be used to increase the work needed to check a hash to make brute-force attacks harder
; The default is 10 (the recommended value). An increase by 1 makes the computation take 2x as long as before.
Debug CreatePasswordHash("secret", 12)
#PB_Cipher_HMAC flag
Code: Select all
; For the HMAC computation you use any regular fingerprint function and specify a digest algorithm combined
; with the #PB_Cipher_HMAC flag. You also must specify a secret key to use in the HMAC computation.
; You can optionally specify the string format for the HMAC key (default is UTF-8)
; Use hmacSha256 with both key and message in ascii
; Should be 4643978965ffcec6e6d73b36a39ae43ceb15f7ef8131b8307862ebc560e7f988
UseSHA2Fingerprint()
Debug StringFingerprint("the message to hash here", #PB_Cipher_SHA2|#PB_Cipher_HMAC, 256, #PB_Ascii, "the shared secret key here", #PB_Ascii)
DeriveCypherKey() function
Code: Select all
; The DeriveCyptherKey() function lets you generate a key of any length for encryption (or other purposes)
; from a password.
;
; Input:
; - the password
; - a salt value (should be randomly choosen but does not have to be secret)
; - an iteration count (more iterations means more work to compute the key, so harder brute-force attacks)
; - the output buffer and size of the key in bits
; - A cypther plugin for a digest function and the bit size for the digest function
;
; To get the same key for decryption the function has the be called with the same parameters again.
; Only the password has to be kept secret. The rest just has to be remembered somewhere (or hard-coded).
;
; This function implements the PBKDF2 algorithm so it should be able to create matching keys for other
; tools that use the same set of parameters
UseSHA2Fingerprint()
*Key = AllocateMemory(32)
; Create a 256bit key using SHA-512 hash function and 500000 iterations
; The key size does not have to match the size of the hash function
DeriveCipherKey("SecretPassword", "NonSecretSalt", 500000, *Key, 256, #PB_Cipher_SHA2, 512)
ShowMemoryViewer(*Key, 32)
CompareStructure(), CompareList(), etc.
See here:
https://www.purebasic.fr/english/viewto ... 29#p606129
Re: PureBasic 6.10 beta 1 - Xmas Release - is out !
Posted: Sat Dec 23, 2023 5:20 pm
by Otrebor
Thanks PureBasic team!