jargon

TRK Token.bas

Mar 20th, 2021
612
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. declare sub trk_tok(subject as string="", sep as string=comma, tok(any) as string, section as long=1024)
  3.  
  4. declare sub striptok (subject as string="", delimiter as string=comma, skip as string="", byref buffer as string="")
  5.  
  6. sub trk_tok(subject as string="", sep as string=comma, tok(any) as string, section as long=1024)
  7.  
  8.     if len(sep)=0 or len(subject)=0 then
  9.         redim tok(0 to 1)
  10.         tok(0)=subject
  11.         tok(1)=subject
  12.         exit sub
  13.     end if
  14.    
  15.     dim as long offset=0,count=0
  16.     dim as string buffer
  17.     buffer=subject
  18.    
  19.     redim tok(0 to section)
  20.     tok(0)=subject 
  21.    
  22.     do while offset<len(subject)-len(sep)
  23.  
  24.         buffer=right(buffer,len(buffer)-offset)
  25.         offset=instr(1,buffer,sep)
  26.        
  27.         if offset=0 then
  28.             exit do
  29.         end if
  30.        
  31.         count+=1
  32.         if count>ubound(tok,1) then
  33.             redim preserve tok(0 to count+section)
  34.         end if
  35.        
  36.         tok(count)=left(buffer,offset-1)
  37.     loop
  38.    
  39.     if len(buffer)>0 and offset=0 then
  40.         count+=1
  41.         if count>ubound(tok,1) then
  42.             redim preserve tok(0 to count+section)
  43.         end if
  44.        
  45.         tok(count)=buffer
  46.         buffer=space(0)
  47.        
  48.     end if
  49.    
  50.     redim preserve tok(0 to count)
  51.    
  52. end sub
  53.  
  54. sub striptok (subject as string="", delimiter as string=comma, skip as string="", byref buffer as string="")
  55.     redim as string tok()
  56.     trk_tok subject,delimiter,tok()
  57.     dim as integer token_index=0, buffer_index=0
  58.    
  59.     if ubound(tok,1)<1 then
  60.         exit sub
  61.     end if
  62.    
  63.     buffer=space(0)
  64.    
  65.     for token_index=1 to ubound(tok,1)
  66.         if not(tok(token_index)=skip) then
  67.             if len(buffer)>0 then
  68.                 buffer+=delimiter
  69.             end if
  70.             buffer+=tok(token_index)
  71.         end if
  72.     next token_index
  73.  
  74. end sub
  75.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×