
  '==============
  'CAPTURE PARAMS
  '==============


  dim as string arg(64) 'params array

  '--------------------------------------------   
  function GetFields(string s, string d) as sys    
  '============================================
  ' 
  sys a,b,c,le,i
  sys bg,en 'beginning and end of param    
  '
  '    
  'EXCLUDE EMPTY STRINGS    
  '    
  le=len s    
  if le=0 then return 0    
  if d="" then return 0    
  '    
  b=asc d 'delimiter ascii code    
  i=0     'char index    
  while i<le   
    i+=1   
    a=asc s,i
    '
    'MARK START OF PARAM
    '
    if bg=0 then
      if a<>b then
        if a>32 then bg=i
      end if
    end if    
    '    
    'SKIP QUOTED TEXT " ' `    
    '    
    if a=34 or a=39 or a=96 then    
      while i<le    
        i+=1    
        if i>le then exit while    
        if asc(s,i)=a then  exit while    
      wend    
    end if
    '   
    'MARK END OF PARAM
    '
    if bg>0 then
      if a<>b then
        if a>32 then en=i
      end if
    end if
    '
    'DETECT DELIMITER
    '
    if (a=b)or(i>=le) then
      c+=1 'COUNT
      '
      'CAPTURE PARAM
      '
      if bg>0 then
        arg(c)=mid(s,bg,en-bg+1)
      else
        arg(c)=""
      end if
      bg=0 'CLEAR BEGIN MARKER
      en=0 'CLEAR END MARKER
    end if   
  wend    
  return c    
  end function    

  sys fields  
  string src,d$  
  d$=","  
  src="one, two,three, 'and, this, is, a, quoted, field'"  
  
  ' 
  fields=getFields(src,d$)  
  
  Print arg(3)
  Print arg(4)  