'VU_STOCK - show all stock items & balances for given prodcode - no transfer "pm menu.psl"
' 26/06/02 - checked for unused variables


external   dpath vloadif() arytostr() navrecs() remove() spath ipath userid
external   sch scw messline() strcount() messbox() entryline() bgp
external   bpopdb() dsa findcolpop() popuplist() colpopup() fgp bbd fgi bgi
external   progress() vunloadif() messboxwait() progtag() exception() $menu
external   Background()

public     ptstr ptval ptary[1] prodcode desMRC $rollnr psa $ccwcode $stock #ordwidth

global     CheckReservations() DisplayCustomer1() y2 ChooseStock() y cat y3
global     ReturnToMenu() ChooseColour() $popstr #nritems strtcol $choice
global     i $popcol S_prods Titles() ShowStock() x FindRolls()	#prodrec $mess
global     $ccwidx prodMRC $backing $itemtype ChooseWidth() maxwidth strtrow
global     O_SDelivery() O_SReqns() #reqd Lookup() S_prods1 ShowRemnants()
global     DisplayCustomer2()


MAIN
  single-step off
  file unload all
  Background()
  quiet on
  while true
    repaint off
    x = popuplist(9,33,13,"Carpet Remnants Tiles","",1,0)
    if x = -1
      exit while
    else
      $choice = upper(left(ptstr,1))
    end if
    if $choice="R"
      ShowRemnants()
      continue while
    end if
    x = ChooseStock()
    if x = -2  	
      continue while
    elseif x = -1
      continue while
    elseif x = 1
      continue while
    end if

    x = ShowStock()
    if x = -2  			' no stock
      continue while
    elseif x = -1
      continue while
    end if

  end while

  ReturnToMenu()

END MAIN


FUNCTION FindRolls()		
  repaint off
  vloadif(dpath|"colours.vws")
  order change key "[CodeColourWidth]"
  error off
  $ccwcode = filelookup([Colours.CodeColourWidth],[Colours.CCW_Code],$stock)
' message "$ccwcode is:"&str($ccwcode)
'  = filelookup([Colours.CodeColourWidth],[Colours.CCW_Code],$stock)
  if cerror                   ' CCW_Code not listed
    progress(fgp,bgp," Not listed in COLOURS.DB - creating temp index file ",1)
    progtag(fgi,bgi,$stock)
    $mess = "CCW_Code not shown for"&$stock
    cat = "STOCK"
    x = exception(userid,today,time24,cat,$mess)
    vunloadif(dpath|"unread1.vw")
    $ccwidx = "findroll.idx"
    remove(spath|$ccwidx)
    vloadif(dpath|"stk_carp.vws")
    data query execute "findroll.dfq" index spath|$ccwidx
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'  [Product_Code] = prodcode
'  and
'  [Description_MRC] = desMRC
'  and
'  [Width] = #ordwidth
'  and
'  [Active] = "Y"
'  and
'  not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if cerror
      messboxwait(" No stock held ",0,0,1)
      screen clear box 1 1 sch scw 0 0 no-border
      repaint off
      return (1)
    end if
  else                             'message " CCW_Code found"
    $ccwidx = $ccwcode|".idx"      'message "$ccwidx is:"&str(spath|$ccwidx)
    if file(spath|$ccwidx) = 0     'message " index not found"
      progress(fgp,bgp," Rebuilding index file for"&prodcode&prodMRC,0)
      vloadif(dpath|"stk_carp.vws")
      data query execute "find_CCW.dfq" index spath|$ccwidx
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ [CCW_Code] = $ccwcode                                              ³
'  and
'  not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
      if cerror
        screen shortrestore psa
        messboxwait(" No stock held ",0,0,1)
        return (1)
      end if
    end if
  end if
  vunloadif("stk_carp.vws")
  vloadif(dpath|"vu_stock.vw")
  order change index spath|$ccwidx
  data query execute "not_del.dfq" index "showstck.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'  not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    screen shortrestore psa
    messboxwait(" No stock held ",0,0,1)
    return (1)
  end if
  return (0)
END FUNCTION '  FindRolls()


FUNCTION ShowStock()		' in reqn_stk.vw
local $puar
  repaint off
  if cerror
    messline(" No stock held - press any key to continue ",0,0,1,21,5,72)
    screen shortrestore dsa
    inchar
    screen shortrestore psa
    return (-2)
  end if
  repaint on
  repaint
  Titles()
  screen shortrestore S_prods
  if records > 11
    screen print 22 10 15 1 (format(" "|chr(24)&chr(25)&" more stock to view ","M27"))
  end if

  while true
    ptval = navrecs()
    if ptval = {D} or ptval = {d}
      O_SDelivery()
      vloadif(dpath|"vu_stock.vw")
      repaint on

    elseif ptval = {R} or ptval = {r}
      repaint off
      $rollnr = [RollNr]
      x = CheckReservations()
      vloadif(dpath|"vu_stock.vw")
      repaint on
    elseif ptval = {Esc}
      exit while
    end if
  end while
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  return (-1)
END FUNCTION ' ShowStock()


FUNCTION ChooseColour()
  while true
    $popstr = [Colours]
    x = strcount($popstr)
    if x = -1            ' no colours ie NO stock
       return (1)       ' no carpet
    else
      #nritems = ptval
    end if

    strtcol = 0
    for i = 1 to #nritems
      y = GROUP($popstr,i)
      x = len(GROUP($popstr,i))
      if x > strtcol
        strtcol = x
      end if
    end for
    strtcol = 72 - strtcol

    screen clear box 21 5 22 77 0 0 no-border
    y2 = format(" Select colour and press {Enter} ","M72")
    screen print 21 5 fgp bbd y2

    if ASC(desMRC) = 0
      $popcol = colpopup(7,strtcol,19,[Colours],"",1,0,14,11,0,7)
    else
      $popcol = findcolpop(7,strtcol,19,[Colours],"",desMRC,1,0,14,11,0,7)
      if $popcol = -5
        $popcol = colpopup(7,strtcol,19,[Colours],"",1,0,14,11,0,7)
      end if
    end if
    screen clear box 1 56 1 80 0 0 no-border
    if $popcol = 0
      desMRC = ptstr
      exit while
    elseif $popcol = -1
      screen shortrestore dsa
      return (-1)
    elseif $popcol = -2
      return (-1)
    end if
  end while
END FUNCTION ' ChooseColour()


FUNCTION ReturnToMenu()
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  error off
  while true
    window close
    if cerror
      exit while
    end if
  end while
  file unload all
END FUNCTION


FUNCTION Titles()
  screen print 7 7 14 1 (format("  Roll Nr   Balance     BAR","L29"))
  y2 = (format("(*=ChkMeas'd) - awaiting {D}elivery - {R}eservations - {Esc} exits","M76"))
  screen print 22 3 14 bbd y2
  y3 = (format(" STOCK HELD AT CADOGAN CARPETS ","M76"))
  screen print 23 3 10 bbd y3
END FUNCTION 'Titles()


FUNCTION ChooseWidth()
  while true 			  ' start WIDTH section
    while true
      if [Widths_Available] ! "V"
        maxwidth = right([Widths_Available],5)
        x = entryline(" This carpet is available in any width upto"&maxwidth|"m",5,"","",21,5,72)
        if x = 0
          #ordwidth = value(ptstr)
          if #ordwidth > value(maxwidth)
            messline(" Width cannot be greater than"&maxwidth|"m",0,0,1,21,5,72)
            continue while
          elseif #ordwidth = ""
            continue while
          end if
          exit while
        end if
      end if
      screen print 21 5 fgp bgp y2
      screen shortrestore dsa

      strcount([Widths_Available])
      #nritems = ptval
      strtrow = 19 - #nritems

      screen clear box 21 5 22 77 0 0 no-border
      y2 = format(" Select Width and press {Enter} ","M72")
      screen print 21 5 fgp bbd y2

      while true
        $popstr = [Widths_Available]
        exit while
      end while
      x = colpopup(strtrow,68,20,$popstr,"",1,0,4,0,0,7)
      if x = 0
        #ordwidth = ptstr
        screen shortrestore dsa
        exit while
      end if
    end while
    exit while
  end while				' end of WIDTH section
END FUNCTION ' ChooseWidth()


FUNCTION ChooseStock()
local z $mess1 $mess2 #deflen $wrongprod f1 f2 f3 nr_reqns nr_index
  Background()
  if $choice == "C"
    while true
      prodcode = ""
      vloadif(dpath|"prodselA.vw")
      order change index ipath|"stckcarp.idx"
      screen clear box 1 1 sch scw 0 0 no-border
      repaint off
      y2 = format(" Scroll & {Enter} to select - {Esc} to leave ","M72")
      screen print 21 5 fgp bbd y2
      if #prodrec = 0
        y2 = format("Enter first 4 letters of description or {Esc} to scroll","M72")
        screen print 21 5 fgp bbd y2
        x = bpopdb("prodselA",4,"","[Prod_Back]","L35","[abbrv]","L4","[Product_Code]",7,43,20,80,"",0)
      else
        data goto record record-number #prodrec
        y2 = format(" Scroll or press {F3} to search - {Esc} to leave ","M72")
        screen print 21 5 fgp bbd y2
        x = bpopdb("prodselA",4,"","[Prod_Back]","L35","[abbrv]","L4","[Product_Code]",7,43,20,80,"",0)
      end if
      if x = -1
        screen clear box 21 5 21 5+72 0 0 no-border
        return (-1)
      end if
      prodcode = ptstr
      #prodrec = record
      prodMRC   = [Product_MRC]
      $backing  = [Backing]
      $itemtype = [Item_Type]
      screen shortrestore dsa
      screen print 7 45 15 1 "ÿ"|prodcode|"ÿ"
      screen save 1 1 sch scw S_prods1
      while true                      ' start selection of widths colours etc
        x = ChooseColour()
        if x = -1
          screen clear box 1 1 sch scw 0 0 no-border
          repaint off
          exit while
        elseif x = 1                  ' no colour
          messboxwait(" No stock held ",0,0,1)
          screen clear box 1 1 sch scw 0 0 no-border
          repaint off
          exit while
        elseif x = 2                  ' new colour
          screen clear box 1 1 sch scw 0 0 no-border
          repaint off
          exit while
        end if
        x = ChooseWidth()
        if x = -1
          continue while
        end if
        screen save 7 40 20 80 S_prods
        x=Lookup()
        vloadif(dpath|"prodselA.vw")
        screen shortrestore S_prods1
        screen print 7 45 15 1 "ÿ"|prodcode|"ÿ"
      end while
    end while

  elseif $choice == "T"              '     elseif ptstr = "Tiles"
    while true
      prodcode = ""
      vloadif(dpath|"prodselA.vw")
      order change index ipath|"stk_tile.idx"  ' message "F7 - prodcode is:"&str(prodcode)
      screen clear box 1 1 sch scw 0 0 no-border
      repaint off
      y2 = format(" Scroll & {Enter} to select - {Esc} to leave ","M72")
      screen print 21 5 fgp bbd y2
      if #prodrec = 0
        y2 = format("Enter first 4 letters of description or {Esc} to scroll","M72")
        screen print 21 5 fgp bbd y2
        x = bpopdb("prodselA",4,"","[Prod_Back]","L35","[abbrv]","L4","[Product_Code]",7,43,20,80,"",0)
      else
        data goto record record-number #prodrec
        y2 = format(" Scroll or press {F3} to search - {Esc} to leave ","M72")
        screen print 21 5 fgp bbd y2
        x = bpopdb("prodselA",4,"","[Prod_Back]","L35","[abbrv]","L4","[Product_Code]",7,43,20,80,"",0)
      end if
      if x = -1
        screen clear box 21 5 21 5+72 0 0 no-border
        return (-1)
      end if
      prodcode = ptstr
      #prodrec = record
      prodMRC   = [Product_MRC]
      $backing  = [Backing]
      $itemtype = [Item_Type]
      #ordwidth = str("1.00")
      screen shortrestore dsa
      screen print 7 45 15 1 "ÿ"|prodcode|"ÿ"
      screen save 1 1 sch scw S_prods1
      while true                      ' start selection of widths colours etc
        x = ChooseColour()
        if x = -1
          screen clear box 1 1 sch scw 0 0 no-border
          repaint off
          exit while
        elseif x = 1                  ' no colour
          messboxwait(" No stock held ",0,0,1)
          screen clear box 1 1 sch scw 0 0 no-border
          repaint off
          exit while
        elseif x = 2                  ' new colour
          screen clear box 1 1 sch scw 0 0 no-border
          repaint off
          exit while
        end if

        screen save 7 40 20 80 S_prods
        x=Lookup()
        vloadif(dpath|"prodselA.vw")
        screen shortrestore S_prods1
        screen print 7 45 15 1 "ÿ"|prodcode|"ÿ"
      end while
    end while

  elseif $choice == "A"
    screen clear box 1 1 sch scw 0 0 no-border
    repaint off
    return (1)
  elseif $choice == "V"
    screen clear box 1 1 sch scw 0 0 no-border
    repaint off
    return (1)
  end if
END FUNCTION ' ChooseStock()


FUNCTION O_SDelivery()
local #bline y1 y2 y3
  repaint off
  vloadif(dpath|"purchord.vws")
  order change key "[Product_Code]"
  data query execute "o_sdelvy.dfq" index "o_sdelvy.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ [Product_Code] = prodcode
' ³ and [Order_Status]="P"
' ³ and
' ³ not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messboxwait(" No deliveries awaited ",0,0,1)
    return (0)
  else
    data query execute "o_sdely2.dfq" index "o_sdely2.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ [Carpet_Color] = desMRC
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    if cerror
      messboxwait(" No deliveries awaited ",0,0,1)
      return (0)
    else
      order change physical
      O_SReqns()
      vloadif(dpath|"vu_stck2.vw")
      order change index "o_sdely2.idx"
'       Background()
      if records > 12
        #bline = 22
      else
        #bline = 5 + records
      end if
      y1 = format("Deliveries o/s for"&prodMRC&desMRC,"M70")
      y2 = format(@if(#reqd=0,"",fixed(#reqd,2)&"already requsitioned -")|" press {Esc} to continue ","M70")
      screen print 2 2 fgp bgp y1
      screen print #bline 1 fgp bgp y2
      x = bpopdb("vu_stck2",6,"","[awaited]","L68","[Supplier_Code]","L6","[Order_Nr]",3,5,21,70,"",0)
    end if
  end if
END FUNCTION ' O_SDelivery()


FUNCTION O_SReqns()
  vloadif(dpath|"requsn.vws")
  order change key "[Product_Code]"
   data query execute "osreqns1.dfq" index "osreqns1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [Product_Code]=prodcode
'   and not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
'     screen clear box 1 1 sch scw 0 0 no-border
    return (1)
  end if
  data query execute "osreqns2.dfq" index "osreqns2.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [RollNr]="00000/00"
'   and [CCW_Code]=$ccwcode
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
'     screen clear box 1 1 sch scw 0 0 no-border
    return (1)
  end if
  #reqd=filesum([Length_Quantity])
END FUNCTION ' O_SReqns()


FUNCTION Lookup()
  $stock = left(prodcode|"ÿ"|desMRC|"ÿ"|"Y"|"ÿ"|str(#ordwidth)|repeat("ÿ",36),36)
  x = FindRolls()	
  if x = 1
    return (1)
  elseif x = -1
    return (-1)
  end if
  x = ShowStock()
  if x = -2                            'no stock
    return (2)
  elseif x = -1
    return (-1)
  end if
END FUNCTION 'Lookup()


FUNCTION ShowRemnants()
local y1
  progress(15,10," Please wait ... finding remnants ",0)
  vloadif(dpath|"stk_carp.vws")
  data query execute "vu_remt1.dfq" index "vr1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [Balance]>.01 and
'   [ChckMeas]="R" and
'   and not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    messbox(" No remnants available ",0,0,1)
    Background()
    file unload all
    return (1)
  end if
  vunloadif("stk_carp.vws")

  vloadif(dpath|"vu_remnt.vw")
  order change index "vr1.idx"
  order sort now dictionary "vr2.idx" fields "[Balance]" descending
  while true
    vloadif(dpath|"vu_remnt.vw")
    y1 = format("  Description                                        Balance   BAR  Width","L77")
    screen print 3 2 fgp bgp y1
    x = bpopdb("vu_remnt",6,"","[RemtDesc]","L75","[RollNr]","L0","[RollNr]",4,2,22,78,"",0)
    if x = -1
      Background()
      if $menu="boss"
        messbox(" Print list of remnants? (y/n) ",1,1,1)
        if ptstr=="y"
          messboxwait(" Print list ",0,0,1)
        end if
      end if
      file unload all
      return (0)
    else
      ptstr=[Retail]
      vloadif(dpath|"requsn.vws")
      order change key "[RollReserve]"
      data query execute "any_resv.dfq" index "any_resv.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ QUERY is:  [RollReserve] = "R"|$rollnr                             ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
      if cerror
      else
        DisplayCustomer2()
      end if
    end if
  end while
END FUNCTION ' ShowRemnants()


FUNCTION CheckReservations()
  vloadif(dpath|"requsn.vws")
  order change key "[RollReserve]"
  data query execute "any_resv.dfq" index "any_resv.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ QUERY is:  [RollReserve] = "R"|$rollnr                             ³
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  if cerror
    x = messline(" None for roll"&$rollnr,0,0,1,21,5,72)
    y2 = (format("*=CheckMeasured  -  {R}eservations  -  {Esc} to finish","M72"))
    screen print 22 5 14 bbd y2
    return (0)
  else
    DisplayCustomer1()
  end if
END FUNCTION ' CheckReservations()


FUNCTION DisplayCustomer2()
local i y y1 j z m colSf colSb colIf colIb
  colSf=10
  colSb=13
  colIf=0
  colIb=15
  redimension ptary[records]            ' read into array
  for i = 1 to records
    y = [Job_Nr]|"ÿÿ"|date2([Date_Reserved])|"ÿÿ"|format([Comment],"L25")|right("ÿÿÿÿÿÿÿ"|fixed([Length_Quantity],2)|"m",6)
    y1 = ""
    for j = 1 to len(y)
      z = mid(y,j,1)
      if z = " "
        z = "ÿ"
      end if
      y1 = y1|z
    end for
    ptary[i] = y1
    data goto record next
  end for

  x = arytostr(records)                ' convert array into string
  if x = 0
    m = ptstr
  end if

  while true
    z = 19 - records                    ' message "z is:"&str(z)
    y2 = (format("{Esc} when finished","M72"))
    screen print 22 5 fgp bbd y2
    x = colpopup(z,16,21,m,"",1,0,colSf,colSb,colIf,colIb)
    if x = -1
      return (-1)
    end if
    y1 = ""
    for j = 1 to len(ptstr)
      z = mid(ptstr,j,1)
      if z = "ÿ"       			' change to SOFT space
        z = " "
      end if
      y1 = y1|z
    end for
    ptstr = y1
  end while
END FUNCTION ' DisplayCustomer2()


FUNCTION DisplayCustomer1()
local i y y1 j z m colSf colSb colIf colIb
  colSf=10
  colSb=13
  colIf=0
  colIb=15
  redimension ptary[records]            ' read into array
  for i = 1 to records
    y = [Job_Nr]|"ÿÿ"|date2([Date_Reserved])|"ÿÿ"|format([Comment],"L25")|right("ÿÿÿÿÿÿÿ"|fixed([Length_Quantity],2)|"m",6)
    y1 = ""
    for j = 1 to len(y)
      z = mid(y,j,1)
      if z = " "
        z = "ÿ"
      end if
      y1 = y1|z
    end for
    ptary[i] = y1
    data goto record next
  end for

  x = arytostr(records)                ' convert array into string
  if x = 0
    m = ptstr
  end if

  while true
    z = 19 - records                    ' message "z is:"&str(z)
    y2 = (format("{Esc} when finished","M72"))
    screen print 21 5 fgp bbd y2
    x = colpopup(z,16,21,m,"",1,0,colSf,colSb,colIf,colIb)
    if x = -1
      return (-1)
    end if
    y1 = ""
    for j = 1 to len(ptstr)
      z = mid(ptstr,j,1)
      if z = "ÿ"       			' change to SOFT space
        z = " "
      end if
      y1 = y1|z
    end for
    ptstr = y1
  end while
END FUNCTION ' DisplayCustomer1()

