Using a barcode scanner with Sensoft
Applies to
Sensoft Multiline
Sensoft Vision
Question
Can we use a barcode scanner to input the Spool ID and perhaps other information about the spool?
Solution
Yes. Barcode and QR code scanners typically send the code they read as a string to the current input field. Therefore, let's start by clicking on a field in Sensoft (e.g. Spool ID) and scan a code. The field should now display the string sent by the scanner, e.g. Order_2000331SPA00012
. Normally this is not what you want as your Spool ID. Let's suppose that the correct Spool ID is the piece A00012
and that 2000331
is the Order number.
Sensoft can extract the Spool ID and the Order (and some other fields too) if you set a specify how to do it in the variable Spool ID regex. It is done using a regular expression to search and replace the desired parts of the string. Please contact us (best Daniel Haertle) for setting it up if you are not familiar with regular expressions. For those that are, in the following we describe the specifications of Spool ID regex. Spool ID regex is a string up to 5 lines containing:
Line 1: The search regular expression
Line 2: Replacement for Spool ID
Line 3: Replacement for Product
Line 4: Replacement for Order
Line 5: Replacement for Description
The Spool ID regex in our example could be
^Order_([0-9]*)SP(.*)$
$2
$1
In the first line the regular expression looks for Order_
followed by a series of numbers then SP
followed by an arbitrary string. If the input string, in our case Order_2000331SPA00012
, follows this pattern, we say it matches the regular expression. If it does, as in our example, the parts in round brackets are saved. In our example the Spool ID is in the second round bracket, and is accessed by $2
. We don't want to change the product name, therefore line 3 is empty, and line 4 contains $1
to give the order number. We want to match the whole string or nothing at at all, therefore we use the characters ^
and $
, indicating the start and the end of the string. We refer to regex101 for a description of all special characters.
If there is no match, or Spool ID regex is empty, nothing is replaced and the input string appears in the field as usual.
Where does one set Spool ID regex? Since it is set very rarely, it is hidden. Press Ctrl - D and a new page Debug appears containing the field. After setting it we recommend to hide the Debug page again (by another Ctrl - D) and save the settings.
Where can one test a regular expression? We recommend regex101.com . Sensoft uses the PCRE flavour.
Into which fields can the operator enter the barcode string? In any field that is affected by the replacement and is visible by default. in our example Spool ID and Order are affected by the replacement and in Sensoft Multiline both are visible while in Sensoft Vision only Spool ID is visible by default. So in Sensoft Vision you have to enter it in the field Spool ID while in Sensoft Multiline you can do it in both. BTW, in Sensoft Vision the field Order can be made visible, by clicking with the right mouse button on Spool ID and selecting Show Order.
Some examples:
Spool ID regex | Input string (to Spool ID) | Results | Comments | |||
Spool ID | Product | Order | Description | |||
|
Order_2000331SPA00012 | A00012 | 2000331 | Product and Description left as is | ||
B00012 | B00012 | No match. All left as is | ||||
Order_2000331SPA00012_xxx | A00012_xxx | 2000331 | Probably not what you want | |||
xxx_Order_2000331SPA00012_xxx | xxx_Order_2000331 SPA00012_xxx |
No match. Not what you want | ||||
|
Order_2000331SPA00012 | A00012 | 2000331 | Handles all cases | ||
Order_2000331SPA00012_xxx | A00012 | 2000331 | ||||
xxx_Order_2000331SPA00012_xxx | A00012 | 2000331 | ||||
|
Order_2000331SPA00012 | A00012 | Wire 250 | Special 2000331 | Add constant strings | |
Order_2000345SPA00067 | A00067 | Wire 250 | Special 2000345 | |||
|
A00012xxxxxx | A00012 | Fixed length from string start | |||
xxxA00012xxx | xxxA00 | |||||
|
xxxA00012xxx | A00012 | String length check | |||
A00012 | A00012 | No match. All left as is |