Scripting - Editing Scan Data to append and prepend data

Version 4

    This document goes over an example of how to manipulate scanned data and add a $ to the beginning and end of a Code 128 with the length of 4 characters..

     

    Script( ScriptAP )
    String( sScanData )
    String( sLength )
    String( sDec )
    String( sScan )
    Number( nType )
    Number( nLength )
    Number( nScan )
    Activate( On_Input, sScanData, nScan )

     

        Comment: Data that was scanned
        Scan_String( sScanData, 0 )

     

        Comment: gets the scanned data and stores it into the sScan String, also returns the barcode type
        sScan = Get_Scan_Type_Name( nScan )

     

        Comment: Define Special Handling barcodes
        nType = Get_Scan_Type_Value( "CODE 128" )

     

        Comment: Returns the length of the scanned barcode
        nLength = String_Length( sScanData )

     

        Comment: Converts the length to a decimal
        sDec = Number_To_String_Decimal( nLength )
        sLength = String_Combine( "", sDec )

     

        If( Number_Equal( Get_Scan_Type_Value( sScan ), nType ) )
            If( String_Equal( sLength, "4", 0, TRUE ) )
                sScanData = String_Combine( sScanData, "$" )
                sScanData = String_Combine( "$", sScanData )
                Scan_String( sScanData, 0 )
            End_If
        End_If
        Return

    This screen shot shows a Code 128 barcode type with a length of 4. the script ran and added the $ to the beginning and end of the barcode.

    Scan 1.png

     

    The next screen shot shows a barcode type of code 128 with a length of 5. The script did not run.

    Scan 2.png

    the final Screen shot shows a Codabar with a character length of 4. The script did not run.

    Scan 3.png

     

    You can also add other barcode types in the Special Handling and add more if statements to handle those requests.. If you are going to add more handling of barcode types you will also need to define them above.

     

    Example to add another:

     

    String(nType1)

     

    Comment: Define Special Handling barcodes

    nType1 = Get_Scan_Type_Value( "EAN13" )

     

        If( Number_Equal( Get_Scan_Type_Value( sScan ), nType1 ) )

            If( String_Equal( sLength, "10", 0, TRUE ) )

                sScanData = String_Combine( sScanData, "%" )

                sScanData = String_Combine( "%", sScanData )

                Scan_String( sScanData, 0 )

            End_If