メインコンテンツへスキップ

検索

検索

Commander Trigger File And Bartender Template

コメント

6件のコメント

  • Avatar
    Michael Toupin (mtoupin
    The first thing you're going to want to do is to review the [url="http://s3.amazonaws.com/SeagullBarTender/ftp/WhitePapers/WhitePaper_CommanderExamples_English.pdf"]Commander Examples white paper[/url]. Specifically example 3, using Commander script.

    An appropriate Commander script trigger file for processing based off of your requirements should look something like this:

    %BTW% /AF="C:\labelfilelocation\labelformatname.btw" /PRN="printer" /?QueryPromptName="QueryData" /C=1 /P
    %END%


    Basically there are 5 commands that you're going to want to use.

    /AF - specifies the active format to use
    /PRN - specifies the printer to use
    /? - used with the name of the query prompt or prompts to populate the query prompt on the label
    /C - specifies number of copies to print
    /P - tells BarTender to print the label

    For a full list of commands that can be used, as well as appropriate syntax if necessary, go into BarTender's help and search on 'Command Line Parameter Summary'. Just makes sure to encapsulate your commands in the %BTW% and %END% commands so that Commander can use it, and make sure to specify 'Commander Script' as the data type in your Commander task.
    0
  • Avatar
    Legacy Poster
    Mike, Thanks for the reply. I reviewed the white paper, and I think I understand the command line options well enough now to get them working.
    The only remaining question I have is regarding parsing the trigger file to get the information to the correct prompt.
    For example, given trigger file with this line in it
    LABEL1.btw, PRODUCTXYZ, PRINTERXXX, 14

    How do I get the data parsed and into the command as follows?
    %BTW% /AF="C:\labelfilelocation\LABEL1.btw" /PRN="PRINTERXXX" /?QueryPromptName="PRODUCTXYZ" /C=14 /P

    Thanks,
    0
  • Avatar
    Michael Toupin (mtoupin
    [quote name='RAB_ERIC' timestamp='1345037897' post='3086']
    Mike, Thanks for the reply. I reviewed the white paper, and I think I understand the command line options well enough now to get them working.
    The only remaining question I have is regarding parsing the trigger file to get the information to the correct prompt.
    For example, given trigger file with this line in it
    LABEL1.btw, PRODUCTXYZ, PRINTERXXX, 14

    How do I get the data parsed and into the command as follows?
    %BTW% /AF="C:\labelfilelocation\LABEL1.btw" /PRN="PRINTERXXX" /?QueryPromptName="PRODUCTXYZ" /C=14 /P

    Thanks,
    [/quote]

    There's a couple of ways to do that. The recommended way would be to set up your application so that it outputs the data in the right format.

    If that's not doable for whatever reason, you could conceivably write a vbscript or powershell script to parse the data into the appropriate format, then just execute that using an Operating System command in Commander to use it. Would be as easy as setting up the script to read the first line of the data, populate an array with it, then use that array to populate the command string.
    0
  • Avatar
    Legacy Poster

    s

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    s

     

     

     

     

     

     

     

     

    s

     

     

     

     

     

    s

    0
  • Avatar
    Legacy Poster

    Hi,

     

    I'm trying to solve exactly the same problem like RAB_ERIC mentioned in the first post.

     

    Please, do you have some approach how to elegantly parse the data from txt file and move it to the Commander.

     

    There's a couple of ways to do that. The recommended way would be to set up your application so that it outputs the data in the right format. 

     

    What exactly is the right format?

     

    I'm stuck in this step so I would be really grateful for any help.

     

     

    Thank you,

    Tomáš

    0
  • Avatar
    Legacy Poster

    Hello,

    I finally solve this problem with a little bit of programming in .NET

    The key is to use FileSystemWatcher class

     

    Here is the code:

     

    private void fileSystemWatcher_Created(object sender, FileSystemEventArgs e)
            {
                if (e.Name.Substring(e.Name.Length - 4, 4) == ".txt") //if file is *.txt
                {
                    if (new FileInfo(e.FullPath).Length != 0) //if file is not empty
                    {
                        //read file
                        using (StreamReader sr = new StreamReader(e.FullPath))
                        {
                            string[] str = File.ReadAllLines(e.FullPath); //read all lines
    
    
                            /*
                             * 
                             * ADD LOGIC FOR OBTAINING DATA
                             * 
                             */
    
    
                            if (str[0] != null) //if string is not empty
                            {
                                try
                                {
                                    using (Engine btEngine = new Engine(true))
                                    {
                                        //LabelFormatDocument btFormat = btEngine.Documents.Open(@"path"); //open appropriate layout
                                        LabelFormatDocument btFormat = btEngine.Documents.Open(Properties.Settings.Default.layoutfile); //open appropriate layout
                                        btFormat.SubStrings["UID"].Value = str[0]; //prompt data in layout
                                        btFormat.PrintSetup.IdenticalCopiesOfLabel = 1; //set copies of labels to 1
                                        btFormat.Print(); //print label
                                    }
                                }
                                catch
                                {
                                    MessageBox.Show("Message. \n\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //show messagebox with exception
                                }
                            }
                        }
                    }
                }
                //Delete file
                if (File.Exists(e.FullPath))
                {
                    File.Delete(e.FullPath);
                }
            }
    

     

    0

サインインしてコメントを残してください。