FUNCTION CuttingTicket()
local $prn $prn_nr $carpdatafile
  vloadif(dpath|"goodsout.vws")
  order change key "[Requsn_Nr]"
  while record <= records
    data find "[Requsn_Nr]" equal $refnr options ""
    if cerror
      exit while
    else
      $cplref = [CPL_Ref]              'message "$cplref is:"&str($cplref)
      if len($cplref)>0
        messboxwait(" Cutting Ticket already printed ("|$cplref|") ",0,0,1)
        return (1)
      end if
    end if
    data goto record next
  end while
  vunloadif("goodsout.vws")
  vloadif(dpath|"stk_carp.vws")
  #origsize = filelookup([RollNr],[PhysicalBalance],$rollnr)
  remove("label.idx")
  x=makeidx("goodsout","label.idx","0",5) ' message "x is:"&str(x)
  vloadif(dpath|"ctgtktS3.vw")
  data goto record record-number #precnr
  if cerror                               '   if none - then return
    x = messboxwait(" Record not found ",0,0,1)
  end if
  x = addidxrec("label.idx",str(precord),7)
  order change index "label.idx"

'   while true
'     x = fentrybox(" If you need duplicates, enter TOTAL nr of tickets to print ",2,"*2{#}","1")
'     if x = -1
'       continue while
'     end if
'     $totkts = value(ptstr)
'     messbox(" Confirm total of"&str($totkts)&"tickets to print? (y/n) ",1,1,1)
'     if ptstr == "Y"
'       exit while
'     else
'       continue while
'     end if
'   end while

  $ctgnr = 1
  $ctgtot = 1
  p1 = "ctgtkt_S.dfr"
  p2 = ""               ' p2 = title at top of choice popup ("LABEL")
  p3 = 3                ' p3 = printer to be used (1=HPIII_QC; 2=GEN_EPSN etc)
'   p3 = 1                ' p3 = printer to be used (1=HPIII_QC; 2=GEN_EPSN etc)
  p4 = 1                ' p4 = printer port to use (1,2 etc - network set to use 2=LASER; 3=LABEL)
  p5 = 1                ' p5 = choose VIEW/PRINT 1=PRINT; 2=VIEW; 3=CHOOSE
  p6 = 1                ' p6 = nr of copies
' messboxwait(" Change Printing ",0,0,1)
  PrintReport(p1,p2,p3,p4,p5,p6)
  order change physical
END FUNCTION ' CuttingTicket()
