'PURCHIDX - creates permanent indices for O/S goods from all Suppliers

external   dpath vloadif() pipath 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
message "$_drive is"&$_drive
  pipath = $_drive|"\indices\os_purch\"
  progress(fgp,bgp," Deleting old Suppliers' indices on"&pipath|"˙",0)
  file unload all
  remove(pipath|"*.*")
  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 O/S goods ˙˙˙˙",1)
  progtag(fgi,bgi," Re-indexing"&suppname|" ")
  vloadif(dpath|"purchord.vws")
  order change key "[Supplier_Code]"
  data query execute "ospurchB.dfq" index pipath|"P_"|suppcode|".idx"
' ŚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄæ
' ³ [Supplier_Code] = suppcode and [Order_Status] = "P"                ³
' ĄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŁ
  if cerror
'     x=makeidx(dpath|"purchord.vws",pipath|"P_"|suppcode|".idx","0",5)
    x=makeidx("purchord",pipath|"P_"|suppcode|".idx","0",5)
' message "makeidx for "|suppname|" is:"&str(x)
  end if
END FUNCTION ' Suppliers()

