ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Bar Code functions
  • Overview
  • Reading a bar code in a WINDEV application
  • Reading bar codes with a WINDEV application and using a specialized device
  • Reading a QR Code bar code found in an image (physical image or memory image)
  • Reading a bar code in a WEBDEV website
  • Reading a bar code in an Android application
  • Reading a bar code in an iPhone/iPad application
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
WINDEV, WEBDEV and WINDEV Mobile allow you to create applications for reading bar codes.
  • WINDEV In WINDEV, bar codes are read via a specific device plugged into the serial port of the computer.
    For the QR Code bar codes, you also have the ability to read a bar code found in an image.
    For more details, see Reading a bar code in a WINDEV application.
Reading a bar code in a WINDEV application
WINDEV

Reading bar codes with a WINDEV application and using a specialized device

To read a bar code via a specialized device:
  1. Connect a specific device to the serial port of your computer (depending on the device used, check whether the keyboard is not set to uppercase characters and/or whether the device is configured for an english keyboard).
  2. Read the value of the bar code with the following functions for managing serial ports:
    • sOpen, which opens and initializes the specified serial port (or parallel port).
    • sRead, which reads a string in the input buffer of the specified serial port.
The value of the bar code can be displayed in an edit control.
Note: You can also use a Bar Code control in the window editor.
Example to read a bar code with a specific device connected to the COM1 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
WINDEV

Reading a QR Code bar code found in an image (physical image or memory image)

To read a QR Code bar code found in an image:
  1. Select the image that contains the bar code to decode. This image can be:
    • an image in an Image control.
    • an image file.
    • an image in memory.
  2. Declare a BarCode variable if necessary. The characteristics of the QR Code bar code will be saved in this variable.
  3. Use BCDecode to decode the QR Code.
Example to read a bar code stored in memory using a Web Camera:
// Decode a QR Code from a Camera control
s is Buffer
s = dSaveImageBMP(CAM_MyCamera, inMemory)
bc is BarCode
bc = BCDecode(s)
IF ErrorOccurred = False _AND_ bc.TypeBarCode = BC_QRCODE ...
		_AND_ bc.ContentType =  bcTypeEmail THEN
	Info("Email address: " + bc.Content)
END
Reading a bar code in a WEBDEV website
Reading a bar code in an Android application
Reading a bar code in an iPhone/iPad application
Related Examples:
The Bar Code control Unit examples (WINDEV): The Bar Code control
[ + ] Using a Bar Code control
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/28/2025

Send a report | Local help