Need Help Properly Parsing Input Data Follow

Zack Kowalski

My staff will be using a 2D scanner to scan in a barcode containing 25 sets of IMEIs and ICCIDs. Format is:


What I need is the last 4 characters of each IMEI scanned. I then need to add a prefix to those 4 characters and print out 2 copies of each label.

Let's say

IMEI1 - 355551111101111

IMEI2 - 355551111102222

I need the printed output to eventually be labels that are:






I've tried search and replace where I take the beginning 11 characters of each IMEI and delete them. Then take the comma, ICCID, and pipe delimiter and replace with record separator, but that just leads to 25 sets of last-4-IMEI being included on first label.

I have near-zero VB skills so I am hoping there is a way to do this without VB. 

If anyone has done anything similar and can share some thoughts/code, that would be greatly appreciated.


Pete Thane
Comment actions Permalink

Assuming you are using BarTender 2019 then you could set up a Form Level Action to help you to print the labels. 

The system is quite in depth however as what you will actually need is two "labels". One of these acts as like a front end or input only screen into which your code is scanned, the data manipulated and output as a simple data file for the 2nd label to use,

To configure this:

  1. Create the required label with your data field on it including the Transforms > Truncation (keep characters on right) and the Prefix. With number of Identical Copies set to 2 on the print sreen.
  2. Create a simple text file with some dummy data in it so that each record is a new line, ie on line one, IMEI1 plus a comma and then CCID1 with IMEI2 and ICCID2 configured the same on the next line. For this file only a couple of lines are required. Save this file in a suitable unlocked folder so that read/write permissions wont cause an issue, such as in C:\Labels folder. I called my file WriteIt (as you will see in the screenshots below).
  3. Configure your label created in 1. above to use the above file as a database using the Database Connection Setup button and following the Wizard. Once linked, then connect your IMEI field on the label to field 1 in the database. Save As the label giving it an appropriate name.
  4. Next create a new label, the size etc is not important as this will not print . Once the blank label is displayed on the screen click add a text field to the label and then go into the Properties of the filed and use the Change Data Source Name button and give the field a name, I called mine "TheData"and then click Close to come out of the field.
  5. Click on the Form 1 tab at the bottom to access the manual data entry area. 
  6. On the form use the Data Entry Control dropdown to add a Text Input box on the form and then right click on the box and enter the Properties and then change the Text Label to something suitable like "Scan code" etc.
  7. Now press the Linked Data Source option choose the name you chose in 4. above from the Named Data Sources in the right hand column. Click close to exit the box.
  8. Now right click on the Form 1 tab itself and again choose Properties and then click on the Actions button.
  9. What we now need to configure are three commands, one to replace the | with a carriage return, the second to write the data out into the file from 2. and finally a command to print the label created in 1 and 3. For the first command clcik on the plus symbol to the right of Validate Data and choose Search and Replace from the Tranforms options and click OK to open it.
  10. In the Variable drop down choose the More Variables option and on the new screen select the name of the field you gave in 4 above and when you return to the Search/Replace screen the variable should show something like %TheData%
  11. In the Search for box type | and then in the Replace with box type \u000D
  12. Now again click on the plus symbol next to Validate Data and this time select the Write File option from the File option.
  13. On this screen change the Variable dropdown to %EventData% and then use the Browse button to select the text file you created in 2 above. Make sure you select the Replace File if it already exists option and then then again click on the Validate Data plus button.
  14. This time choose the Execute option and select Print Document and to configure this just use the Browse button to search for the Document and select the label you created earlier. 
  15. Click OK and Close and then File Save As to save this label.

When the sues go to print this label they will be asked to scan the code and this will then create the trigger file used to print the other label. 

As a suggestion, you may want to Save the label created in 3. into a different location then the label saved in you could then use Print Station and so the operators can only open and print the 15 label, but if you do change where label 3 is stored make sure to adjust the Print Document command to suite, 

I hope this helps and here are a couple of screenshots.





Please sign in to leave a comment.