Strip the Terminator
easy
Removes the carriage return a barcode scanner adds to the end of each code.
What it teaches
Scanners and serial devices end a reply with a carriage return ($r), sometimes followed by a line feed ($l). Those characters count in LEN, so '123$r' has LEN 4 and does not match '123' typed in, though both look the same on screen. Removing a fixed number of characters breaks when a scanner changes from $r to $r$l: dropping one character from '123$r$l' leaves '123$r'. Keep what comes before the $r, wherever it is. A reply with no $r, such as 'ABC', is kept whole: FIND gives 0 when it finds nothing, and 0 is not a position in the text.
Parameters
| Tag | Direction | Type | Default | Description |
|---|---|---|---|---|
| Ref_Reply | InOut | STRING | — | A scanner reply as received |
| Ref_Code | InOut | STRING | — | The code without its line ending |
Required behavior
- Every scan, Ref_Code is Ref_Reply up to, but not including, its first carriage return ($r).
- Scanners end a reply with $r, with $r$l, or with nothing, and the same scanner can change after a settings change, so look for the $r instead of counting characters.
- A reply with no $r is copied whole. A reply that is only $r gives an empty Ref_Code.
- Never change Ref_Reply.