BarCode Scanner
Windev supports Bar code scanner device via Serial
Port, Parallel Port and IR Port. Serial Port connection only allows the read
function. Many systems have parallel ports default. So we need to convert
Parallel Port to Serial port to use windev functions.
To convert a Parallel Port to Serial port we need to
do some configurations.
- Install HSM USB Serial Driver
- First we need to scan particular barcode given with HSM USB Serial Driver
Codes to connect a Barcode Scanner via Serial Port :
// Declare the
variables
// Define the number of characters that must be read
nNbCharToRead is int = 13
// Number of pending bytes in the buffer
nNbPendingByte is int
sBuffer is string // Content of the buffer
nSerialPort is int = 1 // COM1 serial port
// Open and initialize the serial port COM1
IF sOpen(nSerialPort, 5000, 5000) THEN
// Read the bar code
// Retrieve the number of pending bytes
nNbPendingByte = sInEntryQueue(nSerialPort)
// Retrieve the value of the bar code only
// if at least 13 characters have been read
IF nNbPendingByte >= nNbCharToRead THEN
sBuffer = sRead(nSerialPort, nNbPendingByte)
// Retrieve the first 13 characters read
sBuffer = Left(sBuffer, 13)
// Display the value of the bar code
// in the "EDT_BarCode" edit control
EDT_BarCode = sBuffer
END
END
// Define the number of characters that must be read
nNbCharToRead is int = 13
// Number of pending bytes in the buffer
nNbPendingByte is int
sBuffer is string // Content of the buffer
nSerialPort is int = 1 // COM1 serial port
// Open and initialize the serial port COM1
IF sOpen(nSerialPort, 5000, 5000) THEN
// Read the bar code
// Retrieve the number of pending bytes
nNbPendingByte = sInEntryQueue(nSerialPort)
// Retrieve the value of the bar code only
// if at least 13 characters have been read
IF nNbPendingByte >= nNbCharToRead THEN
sBuffer = sRead(nSerialPort, nNbPendingByte)
// Retrieve the first 13 characters read
sBuffer = Left(sBuffer, 13)
// Display the value of the bar code
// in the "EDT_BarCode" edit control
EDT_BarCode = sBuffer
END
END
Comments
Post a Comment