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: 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 site
  • Reading a bar code in an image
  • Reading a bar code in an Android application
  • Direct bar code reading with an Android application
  • Reading a bar code in an iPhone/iPad application
  • Direct reading of QR Code bar codes (BCCapture function)
  • Direct bar code reading (Camera control)
  • Reading a bar code in an image
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
WINDEV, WEBDEV and WINDEV Mobile allow you to create applications for reading bar codes.
Reading a bar code in a WINDEV application
WINDEV

Reading bar codes with a WINDEV application: 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.
Remark: A Bar Code control can also be used in the window editor.
Example used to read a bar code with a specific device connected to the serial port COM1:
// 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: Reading a bar code read by a Web Camera and stored in memory:
// 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.TypeContent =  bcTypeEmail THEN
Info("Email address: " + bc.Content)
END
Reading a bar code in a WEBDEV site
WEBDEV - Server code

Reading a bar code in an image

In WEBDEV sites, it is also possible to read the characteristics of a bar code in an image.
To read a 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 bar code will be saved in this variable.
  3. Use BCDecode to decode the bar code.
Example: Reading a bar code in an Image control:
// Decode a QR Code found in an Image control
bc is BarCode
bc = BCDecode(IMG_BarCode)
IF ErrorOccurred = False _AND_ bc.TypeBarCode = BC_QRCODE ...
_AND_ bc.TypeContent =  bcTypeEmail THEN
Info("Email address: " + bc.Content)
END
Reading a bar code in an Android application
Android

Direct bar code reading with an Android application

Two modes are available for reading bar codes:
  • Reading bar codes with BCCapture. This function decodes the information stored in a bar code by using the camera of the device.
    Remarks:
    • This function opens a new window that displays the preview from the device camera. Then, you must:
      • center the bar code to decode in the relevant area.
      • tap to read the bar code.
    • In Android, the Zxing library is used for decoding bar codes (http://code.google.com/p/zxing). If this library is not found on the device, it will be automatically proposed for download.
  • Reading bar codes via the Camera control.
    Simply enable bar code reading in the Camera control. A specific process is run whenever the bar code is read. This process is used to get the characteristics of the bar code read in a variable of type BarCode. For more details, see Camera control: decoding bar codes.
Reading a bar code in an iPhone/iPad application
iPhone/iPad

Direct reading of QR Code bar codes (BCCapture function)

Bar codes are read directly by BCCapture. This function decodes the information stored in a bar code by using the camera of the device.
Remark: This function opens a new window that displays the preview from the device camera. Then, you must:
  • center the bar code to decode in the relevant area.
  • tap to read the bar code.
The characteristics of the bar code are then stored in a variable of type BarCode. The value of the bar code is returned by the RoughValue property and can be displayed in a Bar Code control.
For example:
// Capture the bar code
MyBC is BarCode
MyBC = BCCapture()
 
// Retrieve the content of the bar code and display it
sResult is string = MyBC.RoughValue
BAC_MyBarCodeControl = sResult
iPhone/iPad

Direct bar code reading (Camera control)

Bar codes are read directly using the Camera control in decoding mode.
Remark: The user frames the bar code. A specific process is run whenever the bar code is read. This process is used to get the characteristics of the bar code read in a variable of type BarCode. The value of the bar code is returned by the RoughValue property and can be displayed in a Bar Code control.
For example:
// Decoding a Bar Code process
PROCÉDURE DecodeBarCode(bc is BarCode)
// Retrieve the content of the bar code and display it
sResult is string = bc.RoughValue
BAC_MyBarCodeControl = sResult
For more details, see Camera control: decoding bar codes.
iPhone/iPad

Reading a bar code in an image

In iPhone/iPad applications, it is also possible to read the characteristics of a bar code in an image.
To read a 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 bar code will be saved in this variable.
  3. Use BCDecode to decode the bar code.
Example of a barcode read by a Web Camera and stored in memory:
// Decode a QR Code found in an Image control
bc is BarCode
bc = BCDecode(IMG_BarCode)
IF ErrorOccurred = False _AND_ bc.TypeBarCode = BC_QRCODE ...
_AND_ bc.TypeContent =  bcTypeEmail THEN
Info("Email address: " + bc.Content)
END
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/22/2023

Send a report | Local help