4 Replies Latest reply on Mar 27, 2015 8:53 AM by Faur Arama

    How to write a dispatch script to checkout a selected file?

    Bobby Penland

      I have been trying to write a dispatch script to checkout a selected file. When I run the script as a command it checks out both the SLDPRT and SLDDRW files. When I run the script after a flow transition only the SLDPRT gets checked out. I am trying to create a script that checks out a file, updates a variable, then checks the file back in. I specifically want this script to work with SLDDRW files.

        • Re: How to write a dispatch script to checkout a selected file?
          Faur Arama

          Hello,

          Use %PathToSelectedFile% as parameter to dispatch checkout operation.

          • Re: How to write a dispatch script to checkout a selected file?
            Iftach Priel

            Booby, as Faur said, using %PathToSelectedFile% will checkout only the selected file.

            When dispatch runs during state transition it will run on any file that goes through.

            You may want to put in a JUMP command before the checkout, that sends any file which is not a drawing to the end of the script.

             

            In order to do that, you'll need a set of dispatch variables that isolate the extension in the file name. Take a look at this table:

             

             

            NameTypeValue
            Meaning
            ExtPosStatic stringReverseFind(%NameOfSelectedFile%, .)finds the location of the first "." from right to left (the beginning of the extension)
            FileNameNoExtStatic stringLeft(%NameOfSelectedFile%, %ExtPos%)isolates the name of the file without the extension
            ExtStatic stringRight(%NameOfSelectedFile%, %ExtensionNoDotLength%)isolates the extension
            FileNameLengthStatic stringLen(%NameOfSelectedFile%)number of characters in the full file name
            ExtensionLengthStatic stringSub(%FileNameLength%, %ExtPos%)number of characters in the extension including the "."
            ExtensionNoDotLengthStatic stringSub(%ExtensionLength%, 1)number of characters in the extension without the "."

             

            Once you have these variables in your dispatch, the JUMP command can look at Ext variable and goto label END if it is !=slddrw .

             

            Buy the way, I find it very useful to have an "extension" variable in all my file data cards. I add this variable with a dispatch running every time a file is added to the vault.

            I use this variable in other dispatch scripts as "variable from selected file datacard" so I don't have to build this set of static strings all over every time. Having this variable in your data cards also helps in search cards filters, control logics, and transition conditions.

             

             

            • Re: How to write a dispatch script to checkout a selected file?
              Mario Zahren

              Try this one:

               

              You can add a command "jump" into your dispatch script like this:

               

              If %Ext% is not (!) "slddrw" then go to Exit

               

              For "slddrw"-Extension you have to cut the filename into pieces like this:

               

              Full filename                               = %NameOfSelectedFile%                                                                  -> ABC-DE.slddrw

              %ExtPos%                                  = ReverseFind(%NameOfSelectedFile%, .)                                         -> 6 (.)

              %FileNameLength%                   = Len(%FileNameLength%)                                                                 -> 13 (ABC-DE.slddrw)

              %ExtensionLength%                  = Sub(%FileNameLength%, %ExtPos%)                                             -> 7 (.slddrw)

              %ExtensionNoDotLength%        = Sub(%ExtensionLength%, 1)                                                             -> 6 (slddrw)

              %Ext%                                        = Right(%NameOfSelectedFile%, %ExtensionNoDotLength%)          -> slddrw

               

              Mario

              • Re: How to write a dispatch script to checkout a selected file?
                Faur Arama

                Witch version of EPDM do you use?

                Your file name contains blanks?