ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Bar Code functions
  • Properties specific to BarCodes variables
  • Correspondence between the Content and ContentType properties
  • Functions that use BarCodes variables
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
The BarCodes type is used to handle the information found in a bar code. The characteristics of this barcode can be defined and changed using different WLanguage properties.
The BarCodes type can be used as follows:
  • WINDEV The BarCodes type is mainly used to:
    • generate bar codes in the windows and reports.
    • decode QR Codes (in an image).
    • print the bar codes (iPrintBarCode).
  • WEBDEV - Server code The BarCodes type is mainly used to:
    • generate bar codes in the pages.
    • generate bar codes in the reports.
    • print the bar codes (iPrintBarCode).
  • Android The BarCodes type is mainly used to:
    • decode the bar codes read by the device camera.
    • generate bar codes in the windows.
  • iPhone/iPadIOS WidgetMac Catalyst The BarCodes type is mainly used to:
    • generate QR Code bar codes in the windows.
    • decode the bar codes read by the device camera.
    • decode the QR Code bar codes found in an image.
    • print the bar codes (iPrintBarCode).
Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
Android
// Decode a QR Code
bc is BarCode
bc = BCCapture()
IF ErrorOccurred = False _AND_ bc.TypeContent = bcTypeEmail THEN
    Info("Email address: " + bc.RoughValue)
END
MyQRCode is BarCode
MyQRCode.ContentType = bcTypeText
MyQRCode.TypeBarCode = BC_QRCODE
MyQRCode.Content = "http://www.windev.com"
 
// Assign to a Bar Code control
BAC_BCControl = MyQRCode
// Generate a QRCode with an image
// ------------- Bar code or report initialization code
QRCodeWithImage is BarCode
// Image to be inserted in the center of the barcode
ImageQRCodeCenter is Image
ImageQRCodeCenter = IMG_FLAG
// Type of bar code
QRCodeWithImage.TypeBarCode = BC_QRCODE
QRCodeWithImage.ContentType = bcTypeText
// Image at the center
QRCodeWithImage.Image = ImageQRCodeCenter
// High error correction level to compensate for the image at the center
QRCodeWithImage.CorrectionError = qrcodeLevelH
QRCodeWithImage.ImageProportion = 3
// For an image proportion of 3%, a Level L correction (qrcodeLevelL) would not be enough
// to have a readable bar code
 
// (Initial) value
QRCodeWithImage.Content = "https://www.windev.com"
// In a report, the value can be reassigned:
//- by binding the control to data
//- in the code before printing
//- in the code for reading data in the report
// or anywhere else afterwards
 
// Assign to a Bar Code control
BAC_Invoice = QRCodeWithImage
 
// ------------- Code before printing
BAC_Invoice.Value = "QR code with a flag in the center!"
Remarks

Properties specific to BarCodes variables

The following properties can be used to handle a bar code:
Property nameType usedEffect
ContentAny typeValue of bar code.
  • For QR codes, the type of this value depends on the ContentType property .
    See the note below to find out the correspondence between the type of content and the type of value.
  • When reading bar codes other than QR codes, this property is always of type "String" and its value is the same as that of the RoughValue property.
ContentTypeInteger constantNature of data stored in the bar code:
  • bcTypeText (default value when creating the variable): Plain text
  • bcTypePhone: Phone number
  • bcTypeSMS: SMS number
  • bcTypeEmail: Email address
  • bcTypeContact: Contact description
  • bcTypeLocation: Geographic position
  • bcTypeURL: URL (bookmark). To insert an http address into the bar code, use the cbTypeText type.
    This constant is kept for backward compatibility and it must be used in very specific cases.
  • bcTypeMarket: Link to an application on Google Play (for an Android application only)
  • bcTypeWiFi: Parameters for connecting to a Wi-Fi network (for an Android application only)
Remark: These kinds of data are available for the 2D bar codes (QR Code, Aztec, datamatrix, PDF417, ...). For the bar codes other than 2D bar codes, the data is always text data.
CorrectionErrorInteger constantCorrection level of error: used to define the threshold for reading a damaged bar code.
This property is available for:
  • the QR Code bar codes.
  • the PDF-417 bar codes.
  • the Aztec bar codes.
The following constants are available for the QR Code:
  • qrcodeLevelH: about 30% of encoded words can be restored.
  • qrcodeLevelL: about 7% of encoded words can be restored.
  • qrcodeLevelM: about 15% of encoded words can be restored.
  • qrcodeLevelQ: about 25% of encoded words can be restored.
The selected correction level triggers:
  • the resizing of bar code.
  • the modification of the maximum number of characters allowed in the bar code.
A higher correction level means that the drawing of the bar code will have an important size and that less data will be drawn. On the contrary, a higher correction level means that the bar code will be readable even if the support is damaged.
Tips:
  • If the bar code contains a URL, the level L is sufficient.
  • If a logo is inserted into the bar code, we recommend that you use a higher level (M or Q).
  • If the bar code is intended for printing labels for a warehouse, the level H must be used.
For the PDF-417 bar codes, the correction level of the error corresponds to an integer included between 0 and 8.
For the Aztec bar codes, the correction level corresponds to an integer included between 5 and 95, representing the percentage of error correction. The default value is 33. If the given value is
  • less than 5, the value will be set to 5,
  • greater than 95, the value will be set to 95,
  • negative, the value will be set to 33 (default value).
Android This property is not available.
ImageImage added in the center of the bar code (only for QR Codes). The image can correspond to:
  • a variable of type Image,
  • a character string containing the path of the image file to be used,
  • an image memo item, etc.
Android This property is not available.
ImageProportionRealPercentage of the area occupied by the image added to the center of the barcode (only for QR codes for which the Image property is specified). This value must not exceed half of the area reserved for error correction.
Value of the CorrectionError propertyMaximum value of the ImageProportion property
qrcodeLevelH5
qrcodeLevelL1
qrcodeLevelM3
qrcodeLevelQ 5

Android This property is not available.
OptionsInteger constant (or combination of constants)Characteristics of bar code. These characteristics are mainly used when a bar code is printed by iPrintBarCode. The following constants can be used:
  • BC_Bottom: Bar code located at the bottom of destination rectangle.
  • BC_ControlDigits: Bar codes containing control characters (valid for the BC_CODE128, BC_DATAMATRIX, BC_EAN128, CB_GS1_128 and BC_PDF417 bar codes). By default, control characters are enclosed between "<" and ">". To avoid interpreting these characters as control characters, simply double the first "<":
    • "<C40>" = control character
    • "<<AB>" = <AB> to be encoded in the bar code.
For more details, see The different types of bar codes.
  • BC_CheckDigits: Bar codes containing check characters (valid for the BC_CODE128, BC_DATAMATRIX, BC_EAN128, CB_GS1_128 and BC_PDF417 bar codes).
    If this option is selected, the BC_ControlDigits and BC_Charsets constants are automatically taken into account.
  • BC_CenterH: Bar code centered horizontally in the destination rectangle.
  • BC_CenterV: Bar code centered vertically in the destination rectangle.
  • BC_Right: Bar code aligned to right in the destination rectangle.
  • BC_Extended: Extended bar code (valid for the BC_CODE39 and BC_CODE93 bar codes only).
  • BC_FormatText: Formats the text displayed for the EAN 128 bar codes: brackets are added around AIs in the printed text.
  • BC_Left: Bar code aligned to left in the destination rectangle.
  • BC_Top: Bar code located at the top of destination rectangle.
  • BC_IgnoreFormatting: Ignores the brackets found in a 128, EAN-128 or GS1-128 bar code (valid for the BC_CODE128, BC_EAN128 and CB_GS1_128 bar codes only).
    The brackets allow the users to easily read the bar code but they are not drawn in the code.
  • BC_Charsets: Bar code that uses one or more sets of characters in order to compress the bar code. This set of characters must be defined in the value of bar code.
    For more details, see The different types of bar codes.
  • BC_NotProportional: Adjusts the bar code to the size of destination rectangle.
  • BC_NoText: Displays no text below the bar code (valid for the BC_UPCA, BC_UPCB, BC_EAN13 and BC_EAN8 bar codes only).
  • BC_Text: Displays the text below the bar code.
    The text is normalized for the BC_UPCA, BC_UPCE, BC_EAN13 and BC_EAN8 bar codes.
    For the other types of bar codes, the text can exceed the display border of bar code.
  • BC_TextCenter: Centers the text below the bar code (valid only for BC_CODE128, BC_CODE93, BC_CODE11, BC_EAN128, BC_CODE39, BC_INTER2OF5, BC_CODABAR and BC_MSI bar codes).
  • BC_TextRight: Aligns the text below the bar code to the right (valid only for BC_CODE128, BC_CODE93, BC_CODE11, BC_EAN128, BC_CODE39, BC_INTER2OF5, BC_CODABAR and BC_MSI bar codes).
  • BC_TextLeft: Aligns the text below the bar code to the left (valid only for BC_CODE128, BC_CODE93, BC_CODE11, BC_EAN128, BC_CODE39, BC_INTER2OF5, BC_CODABAR and BC_MSI bar codes).
  • BC_Check: Bar code with check characters (valid for the BC_CODE39, BC_CODE93, BC_INTER2OF5 and BC_CODABAR bar codes only).
  • BC_Vertical: Prints the bar code vertically.
  • BC_90: Prints the bar code vertically.
  • BC_180: Prints the bar code while performing a rotation equal to 180 degrees.
  • BC_270: Prints the bar code while performing a rotation equal to 270 degrees.
RoughValueUnicode stringRough value of bar code.
For barcodes other than QR codes, the value of this property is the same as that of the Content property.
This property is read-only.
Android This property contains the value of the bar code as read by the BCCapture function, regardless of the nature of the data stored in the bar code.
For example, this property corresponds to "mailto:address@mail.com" if a QR Code containing an email address is decoded.
TypeBarCodeInteger constantBar code type:
  • BC_AZTEC: AZTEC bar code.
  • BC_MAXICODE: MaxiCode bar code.
    Android Not available.
  • BC_QRCODE: QR Code. This constant is used by default when creating a BarCode variable.
  • BC_UPCA: UPC-A bar code.
  • BC_UPCE: UPC-E bar code.
  • BC_EAN8: EAN8 bar code.
  • BC_EAN13: EAN13 bar code.
  • BC_CODE39: Code39 bar code.
  • BC_CODE93: Code93 bar code.
  • BC_CODE128: Code128 bar code.
  • CB_GS1_128: GS1-128 bar code (new name for the EAN128 bar code).
  • BC_INTER2OF5: Interleaved 2 of 5 bar code.
  • Android BC_UNKNOWN: Bar code decoded by BCCapture with an unrecognized type.
    Remark: This constant is available in read-only.
  • BC_DATAMATRIX: DATAMATRIX bar code.
    iPhone/iPadIOS WidgetMac Catalyst This type of bar code is not available.
  • BC_PDF417: PDF417 bar code.
  • BC_CODABAR: Codabar bar code.
  • BC_CODE11: Code11 bar code.
    Android This type of bar code is not available.
  • BC_EAN128: EAN128 bar code.
    Android This type of bar code is not available.
  • BC_MSI: MSI bar code.
    Android This type of bar code is not available.
These types are also available for the prints performed by iPrintBarCode.

Correspondence between the Content and ContentType properties

Type of contentType of value (Content property)Remark
bcTypeTextCharacter stringExample: "WINDEV is great!"
bcTypePhoneCharacter stringExample: "0612345678"
bcTypeSMSCharacter string
In read mode: The members of the SMS structure (SMS.Message and SMS.Number) will be automatically filled with the values read in the bar code. the content will correspond to a string in the following format: <Number> + CR + <Message>
In generation: If they exist, the members of the SMS structure (SMS.Message and SMS.Number) will be automatically taken into account. You also have the ability to use a character string in the following format: <Number> + CR + <Message>
Example: "0612345678<CR>Text to send"
bcTypeURLCharacter string
Corresponds to a bookmark. The content will be encoded in the following format: "urlto::URL". For example: "urlto::http://www.windev.com". Some decoders do not support this type of content.
To specify an http address, use the cbTypeText type.
Remark: This constant is kept for backward compatibility and it must be used in very specific cases.
Example: "http://www.google.com"
bcTypeMarketCharacter stringExample: "market://search?q=pname:com.company.application"
bcTypeWiFiCharacter stringCharacter string in the following format:
<SSID> + TAB + <Security protocol>+ TAB + <Key>
Example: "MyNetwork<TAB>WPA<TAB>pwd"
bcTypeEmailCharacter stringExample: "name@email.com"
bcTypeContactEmpty.
In read mode: The members of the mContact structure will be automatically filled with the values read in the bar code.
In generation: The members of the mContact structure will automatically be used to generate the bar code.
bcTypeLocationgeoPosition variable.
In read mode: The Latitude and Longitude properties of the variable will be automatically filled with the values read in the barcode.
In generation: The Latitude and Longitude properties of the variable will be automatically used to generate the barcode.

Functions that use BarCodes variables

BCCaptureDecodes the information stored in a bar code by using the device camera (Android, iPhone, iPad).
BCDecodeDecodes the information stored in a QR Code bar code.
iPrintBarCodePrints a bar code (inside a rectangle).
Remark: You can use VariableReset to reset the content of a BarCode variable.
Related Examples:
Android Inventory Android (WINDEV Mobile): Android Inventory
[ + ] This application is used to perform inventories and to save the results in a database.
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/23/2023

Send a report | Local help