8 Replies Latest reply on Jun 6, 2014 8:06 AM by Brian McEwen

    dispatch scripts that could append existing string

    Rick Lacouture

      I have created a few dispatch scripts that adds a unique agency certificate number to a variable field; what I'm finding now is that this particular field could have more than one of these certificate numbers.  There could be infinate combinations, so creating multiple scripts would not be an option.  I do not want to overwrite what is already there, so I was wondering if anyone knows a syntaxt that would allow me to append a string of text.

       

      ...or does anyone have another possible solution instead of using the dispatch?

      -Rick

        • Re: dispatch scripts that could append existing string
          Brian McEwen

          I think it is all in the Dispatch variables.  That is where most string work takes place in the limited actions allowed by Dispatch.

           

          Something like this:

          d_InitialString = gets the "Variable value from the Selected files datacard"

          d_append = is the new string you want to add

          d_FinalString = %d_InitialString%%d_append%

           

          And d_FinalString is the Dispatch variable you will use in the Set Card Variable part of the Dispatch script.

            • Re: dispatch scripts that could append existing string
              Rick Lacouture

              I'm not rerally a programmer, so I cannot seem to find those dispatch variables.  I have attached a couple images that may help understand what I have done.

              001.png

              002.png

                • Re: dispatch scripts that could append existing string
                  Brian McEwen

                  The way I'm picturing it there would only be one "Set card variable" step in the script.  Basically you get all the info together and manipulate it by combining Dispatch variables, and then you write it once to the Card variable you want to change (AgencyVds etc).

                   

                  See the Variables button in your first image?  That is where you create variables just for Dispatch to use.

                   

                  In your second image - the G4081039 value - Click the -> arrow to the right of that box and you will see Userdefined Variables - that is where you point to the variable you created.

                   

                  G4081039... Did you just enter an example while you are figuring it out? I assume it will not always be the same so you will want variables there. 

                   

                  As far as where you get the second string value to append - that can come from another variable on the data card - or you can have an Edit Box step in the Dispatch action - where the user enters the value - to capture that d_append would need to be a Runtime Variable.

                   

                  It will take some experimentation and testing if you have not done this before.

                    • Re: dispatch scripts that could append existing string
                      Rick Lacouture

                      Ok, I think I understand.  Please see the new image to be sure I have my syntax correct for the dispatch variable.  The where you state to "point to the variable you created"; are you referring to the d_Final String as shown in the new second image.

                       

                      I appreciate your help very much!!!

                      I think we're close...

                       

                      003.png

                      004.png

                        • Re: dispatch scripts that could append existing string
                          Brian McEwen

                          Looks good! That is how I imagined it based on what I understood of your process.  You can call the variables whatever you want by the way, whatever makes sense to you.  The "d_" is a good programming convention to avoid confusion with card variables.

                           

                          The Edit Box step (for the d_Append value) can either be before the "For all documents" or after if you want the user to enter a different value for each selected file. Also consider a Combo box if you want to control the exact values they can pick from.

                           

                          Then test it with some junk files.

                            • Re: dispatch scripts that could append existing string
                              Rick Lacouture

                              That worked out GREAT!!!  his will save so much time. My users will be thrilled.

                              Thanks again!

                              Rick

                                • Re: dispatch scripts that could append existing string
                                  Rick Lacouture

                                  Ok one more question...

                                  After trying it on various filetypes, the d_InitialString does not get added to SolidWorks or AutoCAD files. So, when I try to add a different selection from the combobox, the initial string gets replaced by the selected d_Append value.  Though, the script works perfecrtly on TXT, PDF, and XLS filetypes.

                                   

                                  I also added a space between the two variables on d_FinalString = %d_InitialString% %d_Append%; I even added the word "and"

                                  (%d_InitialString% and %d_Append%) to the string and the final value on the data card variable shows " and the selected value".

                                   

                                  Forall situations, the files are checked in and are at the same states.

                                  Any ideas why this may be happening?

                                    • Re: dispatch scripts that could append existing string
                                      Brian McEwen

                                      I'm not sure what is going on.  One thing you can try is to add an Ok MessageBox and display all the values for your variables.  Helps diagnosis the problem if one of them is blank or whatever. 

                                       

                                      Adding a space or static text to the string is not an issue.

                                       

                                      ...May be a data card thing.  Do you have one data card for TXT, PDF, XLS and a different one for CAD? Try to figure out if the variable is set up differently on each.  It sounds like it is failing to pick up the d_InitialString value from CAD datacards.  [[typo edited]]