'SUPPRNGE - creates permanent indices for product ranges from all Suppliers

external   dpath vloadif() prpath sch scw progress() fgp bgp remove()
external   progtag() bgi fgi makeidx() $drive

public     ptstr suppcode

global     x Suppliers() i suppname $_drive


MAIN
single-step off
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
if len($drive)=1
$_drive=$drive|":"
else
$_drive=$drive
end if
  prpath = $_drive|"\indices\supprnge\"
  progress(fgp,bgp," Deleting old Suppliers' price indices on"&prpath|"˙",0)
  file unload all
  remove(prpath|"*.*")
  vloadif(dpath|"supplier.vws")
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  for i = 1 to precords
    suppcode = [Supplier_Code]
    suppname = [Name]
    if not (deleted)
      Suppliers()
    end if
    vloadif(dpath|"supplier.vws")
    data goto record next
  end for
  file unload all
END MAIN


FUNCTION Suppliers()
  progress(fgp,bgp," ˙˙˙˙Building new index files for Supplier's price lists ˙˙˙˙",1)
  progtag(fgi,bgi," Re-indexing"&suppname|" ")
  vloadif(dpath|"products.vws")
  order change key "[Supplier_Code]"
  data query execute "supprnge.dfq" index "x.idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
' ³ [Supplier_Code] = suppcode                                         ³
'   and
'   [Item_Type] <> "C"
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
  if cerror
    x=makeidx("products",prpath|"PR"|suppcode|".idx","0",5)
  else
    order sort now dictionary prpath|"PR"|suppcode|".idx" fields "[Product_MRC]" ascending
  end if
END FUNCTION ' Suppliers()
