Dim $dyn
$dyn = CreateObject("DynamicWrapper")
$=$dyn.Register("C:\Windows\System\Csp2.dll","csp2Init","i=l","f=s","r=l")
$=$dyn.Register("C:\Windows\System\Csp2.dll","csp2ReadData","f=s","r=l")
$=$dyn.Register("C:\Windows\System\Csp2.dll","csp2ClearData","f=s","r=l")
$=$dyn.Register("C:\Windows\System\Csp2.dll","csp2PowerDown","f=s","r=l")
$=$dyn.Register("C:\Windows\System\Csp2.dll","csp2GetASCIIMode","f=s","r=l")
$=$dyn.Register("C:\Windows\System\Csp2.dll","csp2GetPacket","i=dll","f=s","r=l")
$=$dyn.Register("C:\Windows\System\Csp2.dll","csp2GetCodeType","i=lsl","f=s","r=l")
$=$dyn.Register("C:\Windows\System\Csp2.dll","csp2TimeStamp2Str","i=dsl","f=s","r=l")
ReadBarCode
Function ReadBarCode
Dim $nRC ;As Long
Dim $nNumOfBarcodes ;As Long
Dim $i ;As Long
Dim $j ;As Long
Dim $arrbyteBarcode[99] ;As Byte '100 elements
Dim $nBytesRead ;As Long
Dim $bstrBarcode ;As String
Dim $bstrTmp ;As String * 50
;Determine if we can read the data
$nRC = $dyn.csp2ReadData
If $nRC > 0
$nNumOfBarcodes = $nRC
? "Reading " + CStr($nRC) + " Barcodes at " + @Time
;Check to see that we are in ascii mode...
If $dyn.csp2GetASCIIMode = "PARAM_ON"
? "ASCII Mode ON"
For $i=0 To $nNumOfBarcodes-1
$nBytesRead = $dyn.csp2GetPacket($arrbyteBarcode[0], $i, 100)
If $nBytesRead > 0
;Display the Barcode type
$nRC = $dyn.csp2GetCodeType($arrbyteBarcode[1], $bstrTmp, Len($bstrTmp))
? $bstrTmp
$bstrBarcode = " "
; display the barcode is ascii
; skip the length, type, .... timestamp
For $j=2 To $nBytesRead-5
$bstrBarcode = $bstrBarcode + Chr($arrbyteBarcode[$j])
Next
;Display the timestamp
$nRC = $dyn.csp2TimeStamp2Str($arrbyteBarcode[$nBytesRead - 4], $bstrTmp, Len($bstrTmp))
? $bstrBarcode + " " + Left($bstrTmp, 20
EndIf
Next
Else
;Add binary mode packets handling here..
? "Binary Mode ON"
EndIf
Else
? "No Barcodes to Read."
EndIf
EndFunction