FUNCTION ItemtypeIndex()
local s1 s2 s3 s4 s5 s6 s7 s8
  while true
    vloadif(dpath|"products.vws")
    s1 = "˙˙˙˙˙˙˙ALL"
    s2 = "˙˙Stock˙Carpet"
    s3 = "˙Bespoke˙Carpet"
    s4 = "˙Stock˙Ancillary"
    s5 = "Bespoke˙Ancillary"
    s6 = "˙˙˙˙˙Vinyls"
    s7 = "˙˙˙˙˙Tiles"
    s8 = "˙˙˙˙˙Labour"
    x = popuplist(8,33,16,s1&s2&s3&s4&s5&s6&s7&s8,"",1,0)
    if x = -1
      return (-1)
    end if
    if ptstr = s1
      AllItemtype()
    elseif ptstr = s2
      OneItemtype("stckcarp.idx","C","itemtyp1.dfq","Stock Carpet")

    elseif ptstr = s3
      OneItemtype("bespcarp.idx","B","itemtyp1.dfq","Bespoke Carpet")

    elseif ptstr = s4
      OneItemtype("stckancl.idx","A","itemtyp1.dfq"," Stock Ancillaries ")

    elseif ptstr = s5
      $itemtype = "J" or "O"     ' F5 - Bespoke Ancillaries    J or O
      remove(prpath|"bespancl.idx")
      progress(fgp,bgp," Building new index file ",1)
      progtag(fgi,bgi," Bespoke Ancillaries ")
      order change key "[Product_Code]"
      data query execute "itemtyp4.dfq" index "x.idx"
'       order sort now dictionary prpath|"bespancl.idx" fields "[Product_MRC]" ascending
      order sort now dictionary ipath|"bespancl.idx" fields "[Product_MRC]" ascending

    elseif ptstr = s6
      remove(prpath|"vinyl.idx")
      progress(fgp,bgp," Building new index file ",1)
      progtag(fgi,bgi," Vinyls ")
      order change key "[Product_Code]"
      data query execute "itemtyp2.dfq" index "x.idx"
'       order sort now dictionary prpath|"vinyl.idx" fields "[Product_MRC]" ascending
      order sort now dictionary ipath|"vinyl.idx" fields "[Product_MRC]" ascending


    elseif ptstr = s7
      remove(prpath|"Stk_tile.idx")
      progress(fgp,bgp," Building new index file ",1)
      progtag(fgi,bgi," Stock Tiles ")
      order change key "[Product_Code]"
      data query execute "itemtyp3.dfq" index "x.idx"
'       order sort now dictionary prpath|"Stk_tile.idx" fields "[Product_MRC]" ascending
      order sort now dictionary ipath|"Stk_tile.idx" fields "[Product_MRC]" ascending

      remove(prpath|"Bsp_tile.idx")
      progress(fgp,bgp," Building new index file ",1)
      progtag(fgi,bgi," Bespoke Tiles ")
      order change key "[Product_Code]"
      data query execute "itemtyp5.dfq" index "x.idx"
'       order sort now dictionary prpath|"Bsp_tile.idx" fields "[Product_MRC]" ascending
      order sort now dictionary ipath|"Bsp_tile.idx" fields "[Product_MRC]" ascending

    elseif ptstr = s8
      $itemtype = "F"            ' F8 - Labour                 F
      remove(prpath|"labour.idx")
      progress(fgp,bgp," Building new index file ",1)
      progtag(fgi,bgi," Labour ")
      order change key "[Product_Code]"
      data query execute "itemtyp1.dfq" index "x.idx"
'       order sort now dictionary prpath|"labour.idx" fields "[Product_MRC]" ascending
      order sort now dictionary ipath|"labour.idx" fields "[Product_MRC]" ascending

    end if
  end while
END FUNCTION ' ItemtypeIndex()
