Visual Formatter Page (Examples)
This section shows some example usages for the Visual Formatter.
Code manipulation and type check
The following examples show how to use the visual formatter to manipulate the barcode string, as well as run some checks on the barcode type in order to execute the operations only for certain types of barcode.
Sample 1
If the barcode type is a CODE128, the barcode text contains "00", and there are at least 18 characters after the "00" (20 characters including the "00"), return 18 characters after "00". Otherwise, return the original code.
Sample 2
If the barcode type is a CODE128, the barcode text starts with "A", and the length is 14 characters, return the barcode text without the first character and with "00" as prefix. Otherwise, return the original code.
Sample 3
If the barcode type is a CODE128 GS1, add "]C1" as prefix. Otherwise, return the original code.
Sample 4
If the barcode type is a QRCODE or DATAMATRIX and the length is >= 2, remove the first 2 characters. Otherwise, return the original code.
Sample 5
If the barcode type is EAN8, remove the first character and skip the standard formatter. Otherwise, return the original code.
Sample 6
If the barcode type is DATAMATRIX, return the code removing all "X" characters. Otherwise, return the original code.
Dispatcher usage
Sample 1
If the barcode length is >= 2 and the barcode type is QRCODE, remove the first 2 characters from the barcode. If the barcode length is >= 2 and the barcode type is DATAMATRIX, remove the last 2 characters from the barcode. Otherwise, keep the original barcode.
Dispatcher
Formatter 1
Formatter 2
Sample 2
Same as Sample 1 from Code manipulation and type check but done using a Dispatcher to simplify the charts.
If the barcode type is a CODE128, the barcode text contains "00", and there are at least 18 characters after the "00" (20 characters including the "00"), return 18 characters after "00". Otherwise, return the original code.
Dispatcher
Formatter
Sample 3
CODE32 is managed by the standard formatter, so a dispatcher is required to first run the standard formatter when it is needed to manipulate CODE32. In this example the first character of CODE32 will be removed, while for other barcode types no manipulation is done.
Dispatcher
Formatter
Sample 4
The parsing of GS1 formatted strings can be done in the visual formatter using the "Get GS1 Field Value" block. This block is not intended to parse GS1 Digital Link formatted strings. In order to support that, the standard formatter can be modified to convert the Digital Link content into a GS1-128 and pass it to the visual formatter. In the example, the field corresponding to the Application Identifier 01 is read. It is important to notice that the standard formatter configuration needs to avoid processing the GS1-128 string, otherwise the GS1 fields cannot be parsed correctly.
Dispatcher
Formatter
Properties usage
Sample 1
Adding custom inputs for prefix and suffix values. This is similar to what is done by the standard formatter but can be used also to add strings in any position inside the barcode.
Sample 2
Adding a custom output set to true when the last barcode has been rejected. In the example, all barcodes that are not QRCODE are rejected and the output boolean is set to true.
Sample 3
Adding a custom variable that counts the number of received barcodes that start with "0".
Actions usage
Sample 1
Send Ctrl+A key events before sending the barcode.
NOTE: You can also add a delay after the Ctrl+A events to avoid sending the barcode before the key events have been processed by the system.
Sample 2
Send an intent to start an activity from a test application, including the barcode string as an extra.
Events usage
Sample 1
In case of barcode read, send the barcode without processing. In case of timeout, send a QR code with the string "TIMEOUT" as result.
Sample 2
Send an intent on decoding start. Send the normal barcode when received.