ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
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
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The BarCodes type is used to handle the information found in a bar code. You can define and change the characteristics of this barcode using different WLanguage properties.
The BarCodes type can be used as follows:
  • 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).
Note: 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: " + cb.ValueBrute)
END
MonQRCode is BarCode 
MonQRCode.ContentType = bcTypeText 
MonQRCode.TypeBarCode = BC_QRCODE 
MonQRCode.Content = "http://www.pcsoft.fr" 

// Affectation à un champ Code-barres
CBA_ChampCB = MonQRCode
// Génération d'un QRCode avec une image
// ------------- Code d'initialisation du code-barres ou de l'état
QRCodeAvecImage is BarCode
// Image à mettre au centre du code-barres
ImageCentreQRCode is Image
ImageCentreQRCode = IMG_DRAPEAU
// Type du code-barres
QRCodeAvecImage.TypeBarCode = BC_QRCODE
QRCodeAvecImage.ContentType = bcTypeText
// Image au centre
QRCodeAvecImage.Image = ImageCentreQRCode
// Niveau de correction d'erreur élevé pour compenser l'image au centre
QRCodeAvecImage.CorrectionError = qrcodeLevelH
QRCodeAvecImage.ImageProportion = 3
// Pour une proportion d'image de 3%, une correction de niveau L (qrcodeNiveauL) serait insuffisante
// pour avoir un code-barres lisible

// Valeur (initiale)
QRCodeAvecImage.Content = "https://www.pcsoft.fr"
// Dans un état, la valeur peut-être ré-affectée :
//- par une liaison fichier sur le champ
//- dans le code avant impression 
//- dans le code de lecture des données de l'état
// ou bien n'importe où après

// Affectation à un champ Code-barres
CBA_Facture = QRCodeAvecImage

// ------------- Code avant impression
CBA_Facture.Valeur = "QR Code avec un drapeau au centre !"
Properties

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 the data stored in the bar code:
  • bcTypeText (default value when Variable is created): Plain Text
  • bcTypePhone: Phone number
  • bcTypeSMS: SMS number
  • bcTypeEmail: Address Email
  • bcTypeContact: description from an Contact
  • bcTypeLocation: Geographical 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: Wi-Fi network connection settings (for Android application only)
Remark: These data natures are available for 2D barcodes (e.g. QR Code, Aztec, datamatrix, PDF417, ...).. For the bar codes other than 2D bar codes, the data is always text data.
CorrectionErrorInteger constantError correction level: defines the threshold for reading a damaged barcode.
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: around 30% of encoded words can be restored.
  • qrcodeLevelL: around 7% of encoded words can be restored.
  • qrcodeLevelM: around 15% of encoded words can be restored.
  • qrcodeLevelQ: around 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). This 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:
  • CB_Bas: Barcode positioned at bottom of destination rectangle.
  • CB_CaracterControle: Bar code containing control characters (valid only for bar codes of type CB_CODE128, CB_DATAMATRIX, CB_EAN128, CB_GS1_128 and CB_PDF417). 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.
  • CB_VerificationCharacter: Bar code containing check digits (valid only for bar codes of type CB_CODE128, CB_DATAMATRIX, CB_EAN128, CB_GS1_128 and CB_PDF417)..
    If this option is selected, the BC_ControlDigits and BC_Charsets constants are automatically taken into account.
  • CB_CentreH: Horizontal centering of barcode in destination rectangle.
  • CB_CentreV: Vertical centering of barcode in destination rectangle.
  • CB_Droite: Right-aligned barcode in destination rectangle.
  • CB_Etendu: Extended barcode (valid only for CB_CODE39 and CB_CODE93barcodes).
  • CB_FormateTexte: Formats the text displayed for EAN 128 barcodes: brackets are added around AIs in the printed text.
  • CB_Left: Left-aligned barcode in destination rectangle.
  • CB_Haut: Barcode positioned at the top of the destination rectangle.
  • CB_IgnoreFormatage: Ignores code 128, EAN-128 or GS1-128 brackets (valid only for barcode types CB_CODE128, CB_EAN128 and CB_GS1_128).
    The brackets allow the users to easily read the bar code but they are not drawn in the code.
  • CB_CharacterSets: Bar code using one or more character sets used for bar code compression.. This set of characters must be defined in the bar code value.
    For more details, see The different types of bar codes.
  • CB_NonProportional: Adjusts the barcode to the size of the destination rectangle.
  • CB_SansTexte: Does not display the text under the barcode (valid only for CB_UPCA, CB_UPCB, CB_EAN13 and CB_EAN8barcodes).
  • CB_Texte: Displays the text under the strikethrough 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.
  • CB_TextCenter: Center the text under the strikethrough (valid only for CB_CODE128, CB_CODE93, CB_CODE11, CB_EAN128, CB_CODE39, CB_INTER2OF5, CB_CODABAR, CB_MSI).
  • CB_RightText: Right alignment of the text under the barcode (valid only for barcode types CB_CODE128, CB_CODE93, CB_CODE11, CB_EAN128, CB_CODE39, CB_INTER2OF5, CB_CODABAR, CB_MSI).
  • CB_TextLeft: Left alignment of the text under the barcode (valid only for barcode types CB_CODE128, CB_CODE93, CB_CODE11, CB_EAN128, CB_CODE39, CB_INTER2OF5, CB_CODABAR, CB_MSI).
  • CB_Vérification: Bar code with check digit (valid only for CB_CODE39, CB_CODE93, CB_INTER2OF5 and CB_CODABARbar codes).
  • CB_Vertical: Print barcode vertically.
  • CB_90: Prints barcode vertically.
  • CB_180: Prints the barcode by rotating it 180 degrees.
  • CB_270: Prints barcodes rotated through 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 constantType of bar code:
  • CB_AZTEC: AZTEC-type strikethrough code.
  • CB_MAXICODE: MaxiCode type barcode.
    Android Not available.
  • CB_QRCODE: QR Code-type strikethrough code. This constant is used by default when creating a BarCode variable.
  • CB_UPCA: UPC-A barcode.
  • CB_UPCE: UPC-E barcode.
  • CB_EAN8: EAN8-type barcode.
  • CB_EAN13: EAN13 barcode.
  • CB_CODE39: Code39-type strikethrough code.
  • CB_CODE93: Code93-type strikethrough code.
  • CB_CODE128: Code128-type strikethrough code.
  • CB_GS1_128: GS1-128 strikethrough barcode (new name for EAN128 barcode).
  • CB_INTER2OF5: Interleaved 2 of 5 barcode.
  • Android CB_INCONNU: Barcode decoded by the BCCapture function with an unrecognized type..
    Note: This constant is available in read-only mode.
  • CB_DATAMATRIX: DATAMATRIX-type barcode.
    iPhone/iPadIOS WidgetMac Catalyst This type of bar code is not available.
  • CB_PDF417: PDF417 barcode.
  • CB_CODABAR: Codabar-type barcode.
  • CB_CODE11: Code11-type strikethrough code.
    Android This type of bar code is not available.
  • CB_EAN128: EAN128-type strikethrough code.
    Android This type of bar code is not available.
  • CB_MSI: MSI-type strikethrough code.
    Android This type of bar code is not available.
These types are also available for the prints performed by iPrintBarCode.
Remarks

Correspondence between the Content and ContentType properties

Type of contentType of value (Content property)Remark
bcTypeTextCharacter stringExample: "WINDEV is good!"
bcTypePhoneCharacter stringExemple: "0612345678"
bcTypeSMSCharacter string
Read: The members of the SMS structure (SMS.Message and SMS.Number) will be automatically populated with the values read from the strikethrough code.. the content will correspond to a string of the form: + RC +
In generation: If they exist, members of the SMS structure (SMS.Message and SMS.Number) will be automatically taken into account.. It is also possible to use a character string of the form: + RC +
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.pcsoft.fr". Some decoders do not support this type of content.
To specify an http address, use the cbTypeText type.
Note: This constant is kept for compatibility and 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.
Read: The members of the mContact structure will be automatically filled in with the values read from the barcode..
In generation: mContact structure members will be automatically used to generate the barcode.
bcTypeLocationgeoPosition variable.
In read mode: The Latitude and Longitude properties of the Variable will be automatically filled in with the values read from 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).
Note: To reset the contents of a variable of type CodeBars, use function VariableReset.
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: 09/19/2024

Send a report | Local help