バー コード スキャナー - xDeviceBarcodeScanner

Define_Com Class(#xDeviceBarcodeScanner) Name(#BarcodeScanner)

Evtroutine Handling(#COM_OWNER.Initialize)
  Clr_List Named(#BarcodeTypes)
  #STD_TEXTS := 'upca'
  Add_Entry To_List(#BarcodeTypes)
  #STD_TEXTS := 'code128'
  Add_Entry To_List(#BarcodeTypes)
  #STD_TEXTS := 'qrcode'
  Add_Entry To_List(#BarcodeTypes)
  #STD_TEXTS := 'code39'
  Add_Entry To_List(#BarcodeTypes)
  #STD_TEXTS := 'itf14'
  Add_Entry To_List(#BarcodeTypes)
  #Scanner.Enabled := false
Endroutine

Evtroutine Handling(#BarcodeScanner.Initialize)
  #Scanner.Enabled := true
Endroutine

Evtroutine Handling(#Scanner.Click)
  Define Field(#vrccItemCount) Type(*INT)
  Define Field(#vrccIx) Type(*INT)

  #BarcodeScanner.ScanMultiple := (#ScanMultiple.ButtonState = Checked)
  #BarcodeScanner.AllowDuplicates := (#AllowDuplicates.ButtonState = Checked)

  #BarcodeScanner.ClearBarcodeTypes()
  For Each(#item) In(#BarcodeTypes.Items)
    If (#item.Checked = Checked)
      Get_Entry Number(#item.Entry) From_List(#BarcodeTypes)
      #BarcodeScanner.AddBarcodeType( #STD_TEXTS )
    Endif
  Endfor

  #BarcodeScanner.ActivateScanner()
Endroutine

Evtroutine Handling(#BarcodeScanner.Completed) Status(#lStatus) Barcodecount(#lCount) Message(#lMessage)
  Define Field(#vrbcIx) Type(*INT)

  If (#lStatus = OK)
    Begin_Loop Using(#vrbcIx) From(0) To(#lCount - 1)
      #STD_TEXTL := #BarcodeScanner.GetScannedValue( #vrbcIx )
      Add_Entry To_List(#ScannedValues)
    End_Loop
  Endif
Endroutine