'ALLINDEX

external  dpath sch scw vloadif() $drive messbox() progress() progtag() fgi
external  bgi ipath vunloadif() fgp bgp spath remove() strcount() makeidx()
external  shoplist

public    ptstr psa choice ptval $b ftgperiod $ccwcode $itemtype

global    x AllIndex() $key Customers() Arc_Custs() CCW_Code() ImmtOrders()
'  SelectDrs()
global    Carpets() Collections() Suppliers() i #branches #int
global    $ccwidx #prec branchname ImmtFittingDate()


MAIN
single-step off
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  file unload all
message "spath is:"&str(spath)
message "ipath is:"&str(ipath)
' message "Only runs CCW Codes"
  #int=6
'   #days = 32
  x = strcount(shoplist)
  #branches = ptval
  AllIndex()
  repaint off
END MAIN


FUNCTION CCW_Code()
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ create new indices for CCW codes                                   ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  progress(fgp,bgp," Deleting old indices on"&spath|"ÿ",0)
  file unload all
  remove(spath|"*.idx")                'delete old indices
  screen shortrestore psa
  progress(fgp,bgp," Building new index files ",1)
  vloadif(dpath|"colours.vws")
  data goto record first
  while precord <= precords
    $ccwcode = [CCW_Code]
    $ccwidx = $ccwcode|".idx"
    if file(spath|$ccwidx) = 1
      data goto record next
      continue while         ' if index for this Colours.Code exists - goto next record
    end if
    progtag(fgi,bgi,spath|$ccwidx)
    #prec = precord
    vloadif(dpath|"stk_carp.vws")
    order change key "[CCW_Code]"
' message "$ccwcode) is:"&str($ccwcode)
    data query execute "ccw_indx.dfq" index spath|$ccwidx
' x=spath|$ccwidx
' message "x) is:"&str(x)
' message "$ccwcode is:"&str($ccwcode)
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ [CCW_Code] = $ccwcode and [Active] = "Y"                           ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if cerror
' message "ERROR!!"
    end if
    vloadif(dpath|"colours.vws")
    order change physical
    data goto record record-number #prec
    if #prec = precords
      exit while
    end if
    data goto record next
  end while
END FUNCTION 'CCW_Code()


FUNCTION AllIndex()
  messbox(" Starting CUSTOMER indices - press {n} to bypass ",0,1,1)
  smartpeek $_lastkey $key        'message "$key is:"&str($key)
  if $key = 110                   'message "NOT running PIsupinv"
  else                            'message "Starting PIsupinv"
    progress(15,10,"   ÿÿÿÿÿÿRunning Server maintenance programsÿÿÿÿÿÿ  ",1)
    progtag(fgi,bgi," Running CUSTOMER indices ")
    Customers()
  end if
  smartpoke $_lastkey 121         'message "$key is:"&str($key)

  messbox(" Starting Immt Order indices - press {n} to bypass ",0,1,1)
  smartpeek $_lastkey $key        'message "$key is:"&str($key)
  if $key = 110                   'message "NOT running PIsupinv"
  else                            'message "Starting PIsupinv"
    progress(15,10,"   ÿÿÿÿÿÿRunning Server maintenance programsÿÿÿÿÿÿ  ",1)
    progtag(fgi,bgi," Running Immt Order indices ")
    ImmtOrders()
  end if
  smartpoke $_lastkey 121         'message "$key is:"&str($key)
' message "STOP"

  messbox(" Starting CCW_CODES indices - press {n} to bypass ",0,1,1)
  smartpeek $_lastkey $key        'message "$key is:"&str($key)
  if $key = 110                   'message "NOT running PIsupinv"
  else                            'message "Starting PIsupinv"
    progress(15,10,"   ÿÿÿÿÿÿRunning Server maintenance programsÿÿÿÿÿÿ  ",1)
    progtag(fgi,bgi," Running CCW_CODES indices ")
    CCW_Code()
  end if
  smartpoke $_lastkey 121         'message "$key is:"&str($key)

  messbox(" Starting CARPETS indices - press {n} to bypass ",0,1,1)
  smartpeek $_lastkey $key        'message "$key is:"&str($key)
  if $key = 110                   'message "NOT running PIsupinv"
  else                            'message "Starting PIsupinv"
    progress(15,10,"   ÿÿÿÿÿÿRunning Server maintenance programsÿÿÿÿÿÿ  ",1)
    progtag(fgi,bgi," Running CARPETS indices ")
    Carpets()
  end if
  smartpoke $_lastkey 121         'message "$key is:"&str($key)

  messbox(" Starting COLLECTION indices - press {n} to bypass ",0,1,1)
  smartpeek $_lastkey $key        'message "$key is:"&str($key)
  if $key = 110                   'message "NOT running PIsupinv"
  else                            'message "Starting PIsupinv"
    progress(15,10,"   ÿÿÿÿÿÿRunning Server maintenance programsÿÿÿÿÿÿ  ",1)
    progtag(fgi,bgi," Running COLLECTION indices ")
    Collections()
  end if
  smartpoke $_lastkey 121         'message "$key is:"&str($key)

  messbox(" Starting SUPPLIER indices - press {n} to bypass ",0,1,1)
  smartpeek $_lastkey $key        'message "$key is:"&str($key)
  if $key = 110                   'message "NOT running PIsupinv"
  else                            'message "Starting PIsupinv"
    progress(15,10,"   ÿÿÿÿÿÿRunning Server maintenance programsÿÿÿÿÿÿ  ",1)
    progtag(fgi,bgi," Running SUPPLIER indices ")
    Suppliers()
  end if
  smartpoke $_lastkey 121         'message "$key is:"&str($key)
END FUNCTION ' AllIndex()


FUNCTION Suppliers()
  vloadif(dpath|"supplier.vws")
  order sort now dictionary ipath|"suppname.idx" fields "[Name]" ascending
  vunloadif("supplier.vws")
END FUNCTION ' Suppliers()


FUNCTION Collections()
  progress(15,10," Please wait ... finding A/c's for Collections ",0)
'   progtag(fgi,bgi,"Creating index of Aged Drs ")
  vloadif(dpath|"customer.vws")
  data query execute "collectn.dfq" INDEX "collect1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³  [Credit_Status]="N"
'    and
'    not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No accounts for Collection status ",0,0,1)
    return (1)
  end if
  order sort now dictionary ipath|"collectn.idx" fields "[Customer_Name]" ascending
  file unload all
END FUNCTION ' Collections()


FUNCTION Arc_Custs()
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ create new index for Customer names in A_CSTORD & A_CSTMER files   ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  progress(fgp,bgp," Deleting old Arcived Customer indices on"&spath|"ÿ",0)
  file unload all
  screen shortrestore psa
  vloadif(dpath|"a_cstord.vws")
  order sort now dictionary ipath|"a_cstord.idx" fields "[Abbrv_Name]" ascending
  for i = 1 to #branches
    $b = group(shoplist,i)
    progtag(fgi,bgi,"Creating index of archives for branch"&$b)
    order change key "[Branch]"
    data query execute "branches.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ QUERY is:  [Branch] = $b                                           ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if cerror
      messbox(" No archived orders for branch"&$b&"ÿ",0,0,1)
      continue for
    end if
    order sort now dictionary ipath|$b|"_arcord.idx" fields "[Abbrv_Name]" ascending
    order change physical
  end for
  vunloadif("a_cstord.vws")
END FUNCTION 'Arc_Custs()


FUNCTION Customers()
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ create new index for Customer names in CUST_ORD & CUSTOMER files   ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
'   progress(fgp,bgp," Deleting old Customer indices on"&spath|"ÿ",0)
  file unload all

  for i = 1 to #branches
    $b = group(shoplist,i)
  end for
  screen shortrestore psa
  progress(fgp,bgp," Building new index files for Customers ",1)
  vloadif(dpath|"customer.vws")
'   order sort now dictionary ipath|"customer.idx" fields "[Abbrv_Name]" ascending
  for i = 1 to #branches
    $b = group(shoplist,i)   'message "$b is:"&$b
    branchname=case $b ("F","Fulham") ("P","Putney") ("R","Raynes") ("S","Sheen") ("T","Trade") ("W","Warehouse")
    progtag(fgi,bgi,branchname)
    order change key "[Branch]"
    data query execute "branches.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ QUERY is:  [Branch] = $b                                           ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    order sort now dictionary ipath|$b|"_custs.idx" fields "[Abbrv_Name]" ascending
    order change physical
  end for
  vunloadif("customer.vws")

  vloadif(dpath|"cust_ord.vws")
'   order sort now dictionary ipath|"cust_ord.idx" fields "[Abbrv_Name]" ascending
  for i = 1 to #branches
    branchname=case $b ("F","Fulham") ("R","Raynes") ("S","Sheen") ("T","Trade") ("W","Warehouse") ("P","Putney")
    $b = group(shoplist,i)
    progtag(fgi,bgi,branchname)
    order change key "[Branch]"
    data query execute "branches.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ QUERY is:  [Branch] = $b                                           ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    order sort now dictionary ipath|$b|"_orders.idx" fields "[Abbrv_Name]" ascending
    order change physical
  end for
  vunloadif("cust_ord.vws")
END FUNCTION 'Customers()


FUNCTION ImmtFittingDate()
local  f3
  if dayname(today)="Monday"
    f3=days(today)+#int
  elseif dayname(today)="Tuesday"
    f3=days(today)+#int
  elseif dayname(today)="Wednesday"
    f3=days(today)+#int+2
  elseif dayname(today)="Thursday"
    f3=days(today)+#int+2
  elseif dayname(today)="Friday"
    f3=days(today)+#int+2
  elseif dayname(today)="Saturday"
    f3=days(today)+#int+1
  elseif dayname(today)="Sunday"
    f3=days(today)+#int+1
  end if
  ftgperiod = date2(f3)
' message "ftgperiod is:"&str(ftgperiod)
END FUNCTION ' ImmtFittingDate()


FUNCTION ImmtOrders()
  ImmtFittingDate()
  file unload all
' message "#branches is:"&str(#branches)
' message "$branches is:"&str($branches)
  progress(15,10," Searching for Goods not recv'd for imminent jobs ",0)

  vloadif(dpath|"notrecvd.vw")
  for i = 1 to #branches
    $b = group(shoplist,i)   'message "$b is:"&$b
    branchname = case $b ("F","Fulham") ("R","Raynes") ("S","Sheen") ("T","Trade") ("W","Warehouse") ("P","Putney")
    progtag(fgi,bgi,branchname)
    choice=$b                          'message "choice is:"&str(choice)
    order change key "[Job_Nr]"
    data query execute "shopimmt.dfq" index "int1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   left([Job_Nr],1) = choice
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if cerror
      messbox(" NO outstanding goods for imminent jobs ",0,0,1)
' message "makeidx"
      x = makeidx("goodsout",ipath|$b|"_immt.idx","0",3)     'message "makeidx is:"&str(x)
      continue for
    else
' message "ftgperiod is:"&str(ftgperiod)
      data query execute "immtjobs.dfq" index "int.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'     days([Date_Out]) > days(today)
'     and
'     days([Date_Out]) <= days(ftgperiod)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
      if cerror
        messbox(" NO imminent jobs ",0,0,1)
' message "makeidx"
      x = makeidx("goodsout",ipath|$b|"_immt.idx","0",3)     'message "makeidx is:"&str(x)
        continue for
      else
        data query execute "cplprep2.dfq" index "int2.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [RollNr] = "00000/00"
'   or
'   [RollNr] = "BESPOK"
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
        if cerror
          messbox(" NO outstanding goods for imminent jobs ",0,0,1)
          x = makeidx("goodsout",ipath|$b|"_immt.idx","0",3)     'message "makeidx is:"&str(x)
' message "makeidx"
          continue for
        end if
      end if
    end if
'     order sort now dictionary "imm2.idx" fields "[Date_Out]" ascending
    order sort now dictionary ipath|$b|"_immt.idx" fields "[Date_Out]" ascending
'   end if
'     exit while
'   end while
  end for
  vunloadif("notrecvd.vw")
END FUNCTION 'ImmtOrders()


FUNCTION Carpets()
'delete old indices
  file unload all
  progress(fgp,bgp," Removing old index files ",0)
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ create new index for each group                                    ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  progress(fgp,bgp," Building new index files ",1)
  vloadif(dpath|"products.vws")
  progtag(fgi,bgi," Stock Carpet ")
  $itemtype = "C"            ' F2 - Stock Carpet           C
  order change key "[Item_Type]"
  data query execute "itemtyp1.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' [Item_Type] = $itemtype
' and
' [Temporary]="N"
' and
' NOT(deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

  order sort now dictionary ipath|"stckcarp.idx" fields "[Product_MRC]" ascending

  $itemtype = "B"            ' F3 - Bespoke Carpet         B
  progtag(fgi,bgi," Bespoke Carpet ")
  order change key "[Item_Type]"
  data query execute "itemtyp1.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ create new index for each group                                    ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  order sort now dictionary ipath|"bespcarp.idx" fields "[Product_MRC]" ascending

  $itemtype = "A"            ' F4 - Stock Ancillaries      A
  progtag(fgi,bgi," Stock Ancillaries ")
  order change key "[Item_Type]"
  data query execute "itemtyp1.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ create new index for each group                                    ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  order sort now dictionary ipath|"stckancl.idx" fields "[Product_MRC]" ascending

  $itemtype = "J" or "O"     ' F5 - Bespoke Ancillaries    J
'   remove(ipath|"bespancl.idx")
  progtag(fgi,bgi," Bespoke Ancillaries ")
  order change key "[Item_Type]"
  data query execute "itemtyp4.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ create new index for each group                                    ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  order sort now dictionary ipath|"bespancl.idx" fields "[Product_MRC]" ascending

  $itemtype = "F"            ' F8 - Labour                 F
'   remove(ipath|"labour.idx")
  progtag(fgi,bgi," Labour ")
  order change key "[Item_Type]"
  data query execute "itemtyp1.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ create new index for each group                                    ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  order sort now dictionary ipath|"labour.idx" fields "[Product_MRC]" ascending

'   $itemtype = "V" or "W"     ' F6 - Vinyls                 V & W
'   remove(ipath|"vinyl.idx")
  progtag(fgi,bgi," Vinyls ")
  order change key "[Item_Type]"
  data query execute "itemtyp2.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ create new index for each group                                    ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  order sort now dictionary ipath|"vinyl.idx" fields "[Product_MRC]" ascending

  progtag(fgi,bgi," Stock Tiles ")
  order change key "[Item_Type]"
  data query execute "itemtyp3.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ create new index for each group                                    ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  order sort now dictionary ipath|"Stk_tile.idx" fields "[Product_MRC]" ascending

  progtag(fgi,bgi," Bespoke Tiles ")
  order change key "[Item_Type]"
  data query execute "itemtyp5.dfq" index "x.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' [Item_Type]="T"
' and
' [Temporary]="N"
' and
' NOT(deleted)
' ³ create new index for each group                                    ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  order sort now dictionary ipath|"Bsp_tile.idx" fields "[Product_MRC]" ascending
END FUNCTION 'Carpets()

