Dynamically Load Template Based On Data 追蹤

0
Avatar
Legacy Poster

The Scenario:

The system I am working with requires many different templates, which have different formats and arrangements. Due to the nature of how the templates work I believe is it more appropriate to have one template per BarTender document. The user will scan a barcode containing a string in the following format:

 

TemplateName.btw|ImageName.jpg|PartNumber|... and so on.

The delimiting character is '|'.

 

Commander is monitoring a Serial Port to receive the string. What I would like to do is parse the string to extract the token 'TemplateName.btw' and use that to dynamically select a Bartender Template that the user can print. I have solved half of the problem by using CommandScript to choose what BarTender document I would like to load the text file into.

%BTW% /AF="DriveLetter:\Pathway\TemplateName.btw" /D="%Trigger File Name%" /P /R=3 /DD
%END%
<My record>

 

The Problem:

I would like to store my data in the Barcode, and not the CommandScript; encase the script needs to be modified it would be better to be on a global scale, not per Barcode. So this means I would need to do two things:

  1. Find a way to get the first field and set it as a variable. (I'm having the most trouble trying to store it somewhere, since I know BTXML can handle delimitators).
  2. Use transform or another command to create a new file that appends a CommandScript to the data, and using the variable to set /AF="DriveLetter\:Pathway\%Variable%". (Also considered the SaveFile command and using a template, not sure though).

It seems more logical to make use of the SDKs provided or at least make use of a more powerful language that can easily deal with these problems. But if possible I would like to avoid a third-party solution please, I have no problem creating one but maintenance would be a problem in the future.

 

Thank you for the long read, I hope that the description is clear and I appreciate any responses.

3 意見

0
Avatar
Fernando Ramos Miracle
版主
評論操作 永久連結

Hello Dan,

 

1. I'm not sure if I fully understand what you meat when saying "get the first field and set it as a variable", could you please explain in further detail? Not sure if it would be helpful but in BarTender v10.1 we've included Global Data Fields, you'll find more information on the below webpage:

http://www.bartenderbarcodesoftware.com/label-software/whitepapers/WhitePaper_WhatsNewInBT101.pdf

 

2. You could indeed use a "Search and Replace" action (or actions) to add the Commander script to the actual file going to be used as database (you first need to use Commander task to record the incoming data in a text file). This way you could add at the beginning the initial script: %BTW% /AF="\\CoputerName\Pathway\ ; then, substitute the first separator character "|" with the rest of the Commander script " /D="%Trigger File Name%" /P /R=3 /DD

%END%

 

*Note that you'll need to include the two carriage return characters.

 

**Also please note that I've substituted your "DriverLetter:" reference to a mapped drive with a UNC path. Please note that Windows services (such as Commander when running as a service) are not compatible with mapped drives as they are user dependent (won't even exist on a service context).

 

Cheers.

0
Avatar
Legacy Poster
評論操作 永久連結

Hey Fernando,
 
Thank you for the quick response! (You guys are fast around here). I don't think I was too clear about '1.' what I would have liked to do is extract the file name out of the string: 'TemplateName.btw|ImageName.jpg|PartNumber|...' and store it in a variable that I could use in another command. 
 
Anyway, with your help on Search and Replace, I managed to resolve the problem with string manipulation. Thank you very much.
0
Avatar
Fernando Ramos Miracle
版主
評論操作 永久連結

Hello Dan,

 

I'm glad I could be of help.

 

Also please note that on v10.1 we added the "Print Job Field" data source type. One of the field options for this data source type would be "Document Name" that would get you exactly what you require.

 

Cheers.

登入寫評論。