'uses console
'indexbase 1

function dat( bstring s1=null, s2=null) as string
=================================================
  'AssociativeArray 2
  indexbase 1
  static int c[1] 'alignment?
  static string n[1000]
  static string d[1000]
  static int e,i
  '
  if ?s2=0
    for i=e to 1 step-1
      if n[i]=s1
        return d[i]
      endif
    next
    exit function 'not found
  endif
  'storing
  for i=e to 1 step-1 
    if n[i]=s1
      d[i]=s2 'store
      exit function
    endif
  next
  'new record
  e++
  if e>ubound(n)
    'overflow error ...
    exit function
  endif
  n[e]=s1
  d[e]=s2
end function
'
'TEST
dat()
dat("B")=4
dat("B",40)
dat("A")=2 'itr procedures subsas
print dat("A") cr dat("B") cr
wait
