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() 


