PureBasic 6.10 LTS is out !

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
the.weavster
Addict
Addict
Posts: 1576
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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
User avatar
the.weavster
Addict
Addict
Posts: 1576
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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! :P

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 €) :lol:
:wink:
BarryG
Addict
Addict
Posts: 4123
Joined: Thu Apr 18, 2019 8:17 am

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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.
User avatar
useful
Enthusiast
Enthusiast
Posts: 402
Joined: Fri Jul 19, 2013 7:36 am

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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.
Last edited by useful on Sat Dec 23, 2023 11:41 am, edited 1 time in total.
Dawn will come inevitably.
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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.
:wink:
Axolotl
Addict
Addict
Posts: 802
Joined: Wed Dec 31, 2008 3:36 pm

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
the.weavster
Addict
Addict
Posts: 1576
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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.
:wink:
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.
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post by HanPBF »

Anybody checked #PB_EventType_ColumnClick?
I can not find it in 6.10b1.

EventType() gives 8, I guess for click in header
pamen
Enthusiast
Enthusiast
Posts: 193
Joined: Sat Dec 31, 2022 12:24 pm
Location: Cyprus
Contact:

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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
S.T.V.B.E.E.V.
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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)
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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?
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User_Russian
Addict
Addict
Posts: 1518
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post 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
quidquid Latine dictum sit altum videtur
User avatar
Otrebor
Enthusiast
Enthusiast
Posts: 210
Joined: Mon Mar 17, 2014 1:42 pm
Location: São Paulo, Brasil
Contact:

Re: PureBasic 6.10 beta 1 - Xmas Release - is out !

Post by Otrebor »

Thanks PureBasic team!
Post Reply