Break off
Dim $i, $j, $arrbyteBarcode, $bstrTmp, $bstrBarcode
$Port = 15
For $x = 0 to 99
$Test = "" + $Test + $cnt + ","
$cnt = $cnt + 1
Next
$Test = Left($Test,Len($Test)-1)
$Test = Split($Test,",")
$arrbyteBarcode = ByteArray($Test)
$dyn = CreateObject("DynamicWrapper")
; ********************************************************************
; DynaWrap Reference
; ********************************************************************
/*
{'a', sizeof(IDispatch*), VT_DISPATCH}, // a IDispatch*
{'c', sizeof(unsigned char), VT_I4}, // c signed char
{'d', sizeof(double), VT_R8}, // d 8 byte real
{'f', sizeof(float), VT_R4}, // f 4 byte real
{'k', sizeof(IUnknown*), VT_UNKNOWN}, // k IUnknown*
{'h', sizeof(long), VT_I4}, // h HANDLE
{'l', sizeof(long), VT_I4}, // l long
{'p', sizeof(void*), VT_PTR}, // p pointer
{'s', sizeof(BSTR), VT_LPSTR}, // s string
{'t', sizeof(short), VT_I2}, // t short
{'u', sizeof(UINT), VT_UINT}, // u unsigned int
{'w', sizeof(BSTR), VT_LPWSTR}, // w wide string
*/
; ********************************************************************
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2Init", "i=l", "f=s", "r=l")
; (Declare Function csp2Init Lib "csp2.dll" (ByVal nComPort As Long) As Long)
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2ReadData", "f=s", "r=l")
; (Declare Function csp2ReadData Lib "csp2.dll" () As Long)
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2ClearData", "f=s", "r=l")
; (Declare Function csp2ClearData Lib "csp2.dll" () As Long)
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2PowerDown", "f=s", "r=l")
; (Declare Function csp2PowerDown Lib "csp2.dll" () As Long)
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2GetASCIIMode", "f=s", "r=l")
; (Declare Function csp2GetASCIIMode Lib "csp2.dll" () As Long)
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2GetPacket", "i=dll", "f=s", "r=l")
; (Declare Function csp2GetPacket Lib "csp2.dll" (stPacketData As Byte, ByVal lgBarcodeNumber As Long, ByVal maxLength As Long) As Long)
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2GetCodeType", "i=lsl", "f=s", "r=l")
; (Declare Function csp2GetCodeType Lib "csp2.dll" (ByVal CodeID As Long, ByVal CodeType As String, ByVal nMaxLength As Long) As Long)
$nul = $dyn.Register("C:\Windows\System\Csp2.dll", "csp2TimeStamp2Str", "i=dsl", "f=s", "r=l")
; (Declare Function csp2TimeStamp2Str Lib "csp2.dll" (Stamp As Byte, ByVal value As String, ByVal nMaxLength As Long) As Long)
$dOpen = $dyn.csp2Init($Port)
? @error
$dRD = $dyn.csp2ReadData()
? $dRD
$dASCII = $dyn.csp2GetASCIIMode
If $dRD > 0
$nNumOfBarcodes = $dRD
?? "Reading " + CStr($dRD) + " Barcodes at " + @Time
If $dASCII
? "ASCII Mode ON"
debug on
? Vartype($arrbyteBarcode)
; Displays: 8209 = (Byte[] Array right?)
For $i = 0 To ($nNumOfBarcodes - 1)
$nBytesRead = $dyn.csp2GetPacket($arrbyteBarcode[0],$i,100) ; $arrbyteBarcode[0] - can't be right... I would use the same element each time?
If $nBytesRead > 0
$k = $i + 1
$dRD = $dyn.csp2GetCodeType($arrbyteBarcode[1],$bstrTmp,Len($bstrTmp)); $arrbyteBarcode[1] - can't be right... I would use the same element each time?
?? $bstrTmp
$bstrBarcode = " "
For $j = 2 To ($nBytesRead - 5)
$bstrBarcode = $bstrBarcode + Chr($arrbyteBarcode[$j])
?? Chr(arrbyteBarcode[$j])
Next
$dRD = $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
Exit 0
; ******************************************************
Function ByteArray($array)
Dim $stream, $i
$stream = CreateObject("ADODB.Stream")
If @error
Exit @error
EndIf
$stream.Type = 2
$stream.CharSet = "windows-1252"
$stream.Open
For $i=0 to Ubound($array)
$stream.WriteText(Chr(Val("&"+$array[$i])))
Next
$stream.Position = 0
$stream.Type = 1
$ByteArray = $stream.Read
$stream.Close
Endfunction
; ******************************************************