You may find that you need to trim unwanted space characters from a text string in LabeLase Producer, especially when you're relying on a human operator to enter the data. It's too easy for an operator to accidentally enter extra spaces, especially at the end of an entry, without noticing the extra characters. It would be nice if Producer could automatically trim these extra spaces off of the text before it's rendered on the tag layout.
There are some cases where extra space characters won't make much difference in the tag. For example, if the text input is only going to appear in a human-readable text field, then the extra spaces won't be visible and shouldn't cause any problems. However, if the text is going to be encoded into a barcode, the extra spaces can cause all sorts of problems later on in the process, especially if downstream readers and their applications can't handle these extra spaces.
Fortunately, LabeLase® Producer has a built-in facility to handle this little problem. It is called the Function Processor, and it provides a whole set of functions for manipulating strings in a text or barcode field.
For this particular problem of extra spaces, we will use the function called trim() that, as the name implies, trims off leading and trailing whitespace characters (spaces, tabs, etc.) from a text string.
As an example, lets say that we have an Operator Data Entry field that will allow the user to enter a text string. This operator text would be referenced by a text field using the familiar "flag" notation: %1V
Placing %1V into a text or barcode field will cause Producer to fetch the first field from the Operator Data Entry table and insert it into the layout. If the operator has unfortunately entered either leading or trailing spaces into the text, those spaces will come right along with the rest of the text, potentially injecting problems into the tracking system.
To strip the offending whitespace characters, wrap the %1V in a call to the trim() function like this:
:=trim(%1V)
Notice that the function begins with colon and equal sign characters. This is the indicator to Producer that what follows is a special "function". The name of the function, in this case trim, follows the equal sign. The function takes a single argument that is a text string. Here we substitute the %1V to have Producer insert the data from the Operator Entry table. The net effect is that the text string entered by the operator, extra spaces and all, is passed to the trim() function, resulting in the removal of the spaces. The final, trimmed text is then returned from the function and placed into the text or barcode field.
That's all there is to it. Remember to start the function with the := characters and to specify the text to trim in the function parentheses.
Producer has a whole suite of useful functions to manipulate text and numbers. A full description can be found in the functions section of the user manual.