12 Replies Latest reply on Jul 15, 2016 6:43 AM by Karl Heinz Kremer

    Script deployment across multiple pcs

    roby@inthenews

      Regarding one Javascript across multiple Computers

       

      Please bare with me, i am new D:

       

      I have made a script to speed up my workflow, and now it is being adopted by the entire team. Thing is, because

      every user has specific variable values,  every time i need to fix or update anything on it, i have to individually change

      things such as user name (for local folders) and so forth.

       

      I was wondering if there was a way to pass values to the java-script through the shortcut as you would with some programs. 

      (adding -(argument) under general  shortcut properties in windows)

      that way i can just have 1 script on the server, and have everyone run the same script,

      and pass their own arguments to it, rather than have everyone run their own version.

       

      Also, if there is an alternate way to achieve the same purpose, would thank you infinitely for any suggestions


      Thank you!

        • 1. Re: Script deployment across multiple pcs
          George_Johnson MVP & Adobe Community Professional

          No, folder-level JavaScript can't be stored on a server, they are local to each user's machine.

          • 2. Re: Script deployment across multiple pcs
            try67 MVP & Adobe Community Professional

            What you can do, though, is create a folder-level script that defines

            user-specific values (such as username, etc.) and then another script, a

            generic one, that uses those values when needed.

            Then you could update the generic script without needing to create a

            customised version for each user.

            • 3. Re: Script deployment across multiple pcs
              roby@inthenews Level 1

              I have never quite figured out the way to have javascripts use infromation from one another. Is it possible that you can give me an example on how i would accomplish this?


              Sorry for the ignorance, and thanks fro the help man! i really appreciate it.

              • 4. Re: Script deployment across multiple pcs
                try67 MVP & Adobe Community Professional

                It's quite easy. Let's say you have 2 folder-level scripts: script1.js and

                script2.js.

                In the former you have this code:

                var a = "Hello";

                 

                And in the latter you have this code:

                app.alert(a);

                 

                When you open the application you should see an alert window that says

                "Hello".

                 

                Now, there could be some issues related to scope and the order in which the

                scripts are loaded, but that's the basic concept.

                • 5. Re: Script deployment across multiple pcs
                  roby@inthenews Level 1

                  So there is no "include" or "using" or something of the sort in javascript? All the global variables in the scripts folder are being part of the context at all times? I tried it and it did not work.

                  • 6. Re: Script deployment across multiple pcs
                    Test Screen Name Most Valuable Participant

                    This works, but you have to pay close attention to what you are doing, and understand about SCOPE. Scope is how much of the world sees something. Scope is a common concept in programming languages, but it is really icky in JavaScript. I will leave out the worse stuff.

                    Like in a function
                    function something()
                    {
                      var alpha=...
                      ... things that use alpha
                      alpha = 1
                    }

                    The scope of "alpha" is the function "something". You won't see it anywhere else. This setting
                    of alpha won't change something called alpha anywhere else, and won't even be set next time
                    something() is used.

                     

                    The best way to make something global is to create it at global scope, which means OUTSIDE ANY FUNCTION in the startup scripts.

                     

                    function somethingelse()
                    {
                      ...
                      beta = 1
                    }
                    var beta=0  <<---- this is what creates the global beta, the order does not matter.

                     

                    Beta exists at the global level AND EVERYWHERE ELSE. So in the function somethingelse you are setting the same, one and only, global beta. Every call to somethingelse() will set the global beta.

                     

                    function another()
                    {
                      var beta = 3
                      beta = 4 ;
                    }
                    Now, this function makes a NEW beta with its own scope. This beta isn't connected to the global beta at all and calling another() doesn't change the global beta.

                    This is oversimplifying but it should get you started.

                    • 7. Re: Script deployment across multiple pcs
                      roby@inthenews Level 1

                      Please bare with me, I'm a little slow.

                       

                      I understand the concept of scope within a script. I Understand what you explained, but i am still unable to declare a variable top level on one script, and then use it on another one.
                      Would i have to  declare the variable at the top level of the  first script, then run script 2 from the first one and the second would inherit the values?

                       

                      I'm sorry

                      • 8. Re: Script deployment across multiple pcs
                        Test Screen Name Most Valuable Participant

                        All the startup scripts are read at startup, in some undefined order. Any global variables defined at the top level will be usable in all functions (but you cannot use them at top level in other scripts, because of the undefined order).

                         

                        Be SURE you are not putting your var declarations in any kind of function. Your question suggests you are equating "script" with "function", since you can't actually "run" a script at all, Acrobat does that at startup.

                        1 person found this helpful
                        • 9. Re: Script deployment across multiple pcs
                          try67 MVP & Adobe Community Professional

                          I believe the scripts are loaded in alphabetical order, based on their

                          file-name.

                          On Jul 14, 2016 11:59 PM, "Test Screen Name" <forums_noreply@adobe.com>

                          1 person found this helpful
                          • 10. Re: Script deployment across multiple pcs
                            gkaiseril MVP & Adobe Community Professional

                            You can pass the variables as parameters from the first function to the second function as a parameter.

                             

                            Another alternative would be to define the second function within the first function and have the variable declared or defined in the body of the first function before the definition of the second function.

                            • 11. Re: Script deployment across multiple pcs
                              roby@inthenews Level 1

                              Hello Guys, it turned out there was an easier way to achieve what i needed to do, but thanks as you taught me something very useful. What i was looking for was the folder tokens, which are inherited pre defined user folder variables. information in the Javascript Tools guide PDF bundled with the ExtendScript Toolkit, page 56.

                              • 12. Re: Script deployment across multiple pcs
                                Karl Heinz Kremer Adobe Community Professional

                                Acrobat does not support ExtendScript and therefore the ExtendScript documentation also does not apply to Acrobat's JavaScript implementation. You need to stick with the Acrobat API documentation.