PureLibrary Creator - PB 6.20

Share your advanced PureBasic knowledge/code with the community.
User avatar
idle
Always Here
Always Here
Posts: 5835
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Lib - PB 6.20

Post by idle »

and basic test of it

Code: Select all

Global sq.isquint = SquintNew()
Global *key,key.s,SubTrieA,SubTrie_B,val   
  
Procedure CBSquint(*key,*value,*userData)  
    Protected sout.s  
    sout = PeekS(*key,-1,#PB_UTF8)
    If *value 
      PrintN(sout + " " + Str(*userData) + " " + Str(*value))
    EndIf 
    ProcedureReturn 1 
  EndProcedure
  
  Procedure CBSquintWalk(*key,value,*userData)
    Static ct 
    If ct < 1000
      If value     
        PrintN(Str(PeekI(*key)) + " " + Str(value))  
      EndIf
      ct+1 
    EndIf  
  EndProcedure

    OpenConsole() 
    ;test with interface  
    ;key = "subtrieA:"                ;create a subtrie called subtrie_a_ 
    SubTrieA = sq\Set(0,@"subtrieA:",123)    ;Set it with utf8 flag it returns the root of the sub trie 
    
    key = "abc"                                
    sq\Set(SubTrieA,@key,1)          ;key evaluates as subtrieA:abc  to the sub trie  
    
    key = "abcd" 
    sq\Set(SubTrieA,@key,1)          ;key evaluates as subtrieA:abcd  to the sub trie  
    
    *key = UTF8("utf8:" + Chr($20AC) + Chr($A9))  
    sq\Set(SubTrieA,*key,2,#PB_UTF8) ;add it to the sub trie with utf8 key  
    
    key.s = "unicode:" + Chr($20AC) + Chr($A9)  
    sq\Set(SubTrieA,@key,3) ;add it to the sub trie with utf8 key 
    
    *key = Ascii("cde") 
    sq\set(SubTrieA,*key,4,#PB_Ascii) ;add to sub trie with ascii key    
    
    PrintN("value from ascii key " + Str(sq\Get(SubTrieA,*key,#PB_Ascii)))  ;get the value from the ascci key  
    
    key = "abc"                              
    PrintN("value from unicode key " + Str(sq\Get(SubTrieA,@key)))            ;get the unicode key  
    
    PrintN("the stored node aka subtrieA: = " + Str(SubTrieA))   
    PrintN(" look up subtrie node " + Str( sq\Get(0,@"subtrieA:",#PB_Unicode,0)))   
    PrintN(" look up its value  " +   Str(sq\Get(0,@"subtrieA:")))  
    
    PrintN("___ENUM from stored pointer to subtrieA")
    key = "ab"
    sq\EnumNode(SubTrieA,@key,@CBSquint())                 ;returns the root key + sub keys   
         
    sq\Free(0)   
           
    Input() 
moricode
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 25, 2023 3:55 am

Re: Lib - PB 6.20

Post by moricode »

pf shadoko wrote: Wed Dec 11, 2024 8:54 pm PB 6.20 allows library creation
but for the moment, managing optional procedure parameters is a bit tricky.
to remedy this problem I've made a little code
it also adds a “Quick help” giving the procedure syntax
a comment line above the procedure can be added for a quick description of the procedure


PS: this code is a bit messy, if you encounter a problem, please let me know and I'll fix it.


Error when compile this code to purelibrary :

Code: Select all

DisablePureLibrary testlib

ProcedureDLL Realabc(a$,b$,c,d,e=0)
EndProcedure


;ProcedureDLL testabc(a$,b$,c,d,e=0)
; this give error when we have ProcedureDLL in  commented line
; because the pre-processor don't know this is in commented proceduredll  
;EndProcedure

ERROR : testabc2() is not a Function , List , Array or Map
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 385
Joined: Thu Jul 09, 2015 9:07 am

Re: Lib - PB 6.20

Post by pf shadoko »

i will correct this
LinXP
User
User
Posts: 10
Joined: Mon May 07, 2018 9:58 am

Re: Lib - PB 6.20

Post by LinXP »

pf shadoko wrote: Wed Dec 11, 2024 11:01 pm To test a small example:
save this code as ext2D.pb
Hello
please add here an example of creating a help file using DocMaker, and call for help on F1
Post Reply