Parsing Scanned Data
I would like to have an input field where I can scan a QR code and then parse the information into two separate fields.
The QR code contains a Serial Number and an Item Number delimited by a semicolon.
Any help would be greatly appreciated.
Thank you,
Peter Bartsch
-
Peter Thane
★ BarTender Hero ★
You probably need to include a VB script routine to achieve this.
- Add a Text Field off the side of the label and on the Data Source screen give this field a name. I called mine "parsetest". Give the field a default value also containing a semicolon in it.
- On the Data Entry from add a Text Input item and link this to the field you just named above.
- Back on the Template View add on a new text field and make this a Visual Basic Script > Event Controlled Script and then press the Edit with Script Editor button
- The screen should open up with the OnAutoSelectedEvent enabled and in the large box in the middle give the field a default value by typing in Value = "1234" for example
- In the column in the left now choose the OnPostPrompt option and this time in the large box type Value = and then double click on the name you chose in 1 from the Named Data Sources in the column on the left after this type in the other commands below:
Value = Format.NamedSubStrings("parstest").Value
Value1=Instr(1,Value,";",1)
Value1 = Value1-1
Value=left(Value,Value1)
6.
(There probably is a neater solution how this can be achieved with VB if someone with more scripting knowledge were attempting this but I know that this works)
0 -
Peter Thane
★ BarTender Hero ★
Oops added that with out finishing it.....
Click Close when done.
Note: The first line of your routine will be contain the name of the field you entered in 1 above and not "parstest"
The above will display the information before the semicolon but for the data after it
- Copy and Paste the VB Script field you just created
- Go into the Properties and Edit the script to adjust the code to the following
Value = Format.NamedSubStrings("parstest").Value
Value1 = Instr(1,Value,";",1)
Value2 = Len(Value)
Value1 = Value2-Value1
Value=Right(Value,Value1)
Again click Close when done
0 -
Peter Bartsch
★ BarTender Hero ★
Hi Peter That worked great, I now have two fields with the correct parsed info. One with Serial Number and the other with the Item ID. How would I set my Query Prompt to use the value in the ItemID field?
Thank you so much for your help.
Peter
0 -
Anthony Sonck
★ BarTender Hero ★
Was this 2nd part ever resolved? I am in the same boat trying to get successfully parsed data to be pulled into the Query prompt.
I have an entry form for the operator to scan in the parsed QR code from our IQA label which is tied to a named variable. I then have a named variable created for the PartID with the following script as its source:
Left(Format.NamedSubStrings("IQAScan").Value, (InStr(Format.NamedSubStrings("IQAScan").Value, ",")-1))
This is consistently updating correctly to get me the necessary PartID on the label but even when I tried creating a dynamic filter for the database connection I cannot get the description field to populate or get a query prompt to run AFTER this variable is updated in printing. I had tried to setup a VBA script as above for the Query to parse out the needed information to select the appropriate record from our MRP system database, but then I run into the "script did not read from the value property" errors, despite in testing the script it functioning in the editor window. I also tried updating these fields as mentioned above within the OpPostPrompt actions but I just can't seem to get the database query to identify the record after the user hits print.
I even tried having another form to first scan the QR code then entering the issue quantity and preview the label before printing.... Is there an optimal way to be able to enter in the scan 1st then query the database using the parsed PartID from the named variable either with a dynamic filter, vba scripting, or through the Action Builder?
0 -
Peter Thane
★ BarTender Hero ★
I think I missed the second question and saw the "that worked great"!
The database query has to be run first before populating any other fields and you could link the first data entry prompt to your database filter so that is performs a search/lookup when it is scanned but I think there will be an issue with the information being populated in the second field though due to the time it takes to perform the lookup and retrieve the data from the database.
I havent got a scanner that I can test with so not sure but perhaps if you program an intercharacter delay into the scanner then this will get round this.
Would need to have a play, but you maybe able to use a Action on a data entry form to scan the data into, which then parses the data into the two fields and appends the data to the some static data (the name of your query prompts) and then opens your full label and sends these values through to it. I think the prompted data, would need to be sent through something like this /?<query prompt name>="<query prompt value>".
The other way would be to scan the code twice into your data entry form, once set to ignore anything but the database look up value and once the lookup has finished scan the code again and just use the data for your second field. If you add an image > Preview of Template on your form you will be able to see when BarTender has pulled up the database information as the Preview will show this
.
0 -
Anthony Sonck
★ BarTender Hero ★
Thanks for the update Pete, but unfortunately nothing seems to work and the added effort is not something I can afford to devote further to try and get it working the way I would like it to. I have just gone forward with establishing two-form process for Inventory staff to scan the barcode with the PartID alone (not delimited) first, attaching that to a query prompt as a dynamic filter, then scanning the combined (delimited) barcode again for populating the label fields with the part number and lot number while the description is tied to the database field from the initial query prompt value. It works, but I was hoping to be able to populate my named data sources first and then query the database from them easier to allow them to just have to scan one element to get the same results.
0 -
John Peterson
★ BarTender Hero ★
Is this still the way to go?? VB script?
I need to pull fields from a ? delimited scan (3 examples):
[)>?06?146807?5367804302261389??5500005084?00020?PT00003648-P-011?1?EA??
[)>?06?146807?5367804302261396??5500005084?00020?PT00003648-P-011?1?EA??
[)>?06?146807?5367804302261434??5500005077??PT00003648-P-003?1?EA??always the same number of ?, 3rd line just skips a value.
Thankyou
0 -
Peter Thane
★ BarTender Hero ★
If the data is fixed length, particularly the information before what you want to capture and the data itself then you could just use truncation rather than VB keep X characters on left (bits before plus data) then Discard Y characters on left (bits before). Or similar (out of the office so cant test but you may need discard first then keep).
If the parts are not fixed length then you would probably need VB to look for the ?'s and grab the bits of information you need
0
Please sign in to leave a comment.
Comments
8 comments