Extract some characters from scanned barcode data and submit to host

Version 1

    Verified Product Versions

    Wavelink Naurtech CETerm 5.7

    This sample script validates the symbology of the scanned barcode to be EAN128 and then extracts 11 characters of data from the scanned barcode starting from position 2. It then appends a <Carriage Return> to the end of the data and submits it to the host application. Comments are provided next to specific lines of Javascript code.

    • This script only extracts barcodes from EAN128 symbology. If you need to manage a different barcode symbology, you can uncomment "OS.Alert" to see the symbolgy type when you scan a barcode and make the needed change.
    • You may need to adjust the variables "startCharacter" and "length" in the script.
    • Some barcodes contain non-printable characters which differ from the printed label. These extra characters

    mean you may need a different start.

    function OnBarcodeRead( session, data, source, type, date, time )

    {

        // TEST: Uncomment this line to view barcode type

        //OS.Alert( "type= " + type );

     

     

        // TODO: Only strip EAN128 barcode.

        // TODO: Adjust startCharacter and length to extract

        // TODO: the desired data.

        var typeEAN128 = 63;

        var startCharacter = 2;

        var length = 11;

     

     

        // If barcode is EAN128, extract data

        if (type == typeEAN128)

        {

            // Extract part of the data

            data = data.substr( startCharacter, length );

        }

     

     

        // NOTE: When using a script, the configuration postamble is ignored.

        // TODO: Add postamble here if needed.

        //data += "\r";     // Enter

     

     

        // Send barcode to emulator

        CETerm.SendText( data, session );

     

     

        // Return 0 to handle barcode normally

        // Return 1 if handled here

        return 1;

    }