4 Replies Latest reply on Jan 26, 2015 8:06 PM by msfriday

    Read input parameters from a script file name

    Willis77019b Level 1

      I asked this in the main Illustrator forum an hour ago, but then realized that there was a separate forum for script questions…so please forgive the repetition.  I am sure this is a newbie adobe javascript question, but I have looked for some time and cannot figure out the answer. How do I read input parameters from a script file name? For example, let’s say I want to run a script that requires 3 variables as input, but rather than prompting for the values I wish to read them from the script file name … e.g., the file name might be “Myscript.js (my_variable1, my_variable2, my_variable2)” … where variables are all real numbers. So I assume the script name when run should look something like …  Myscript.js (10, 10, 100), but how do I then read these and assign these values to a var statement within the script?

        • 1. Re: Read input parameters from a script file name
          W_J_T Level 4

          Willis77019b wrote:

           

          • How do I read input parameters from a script file name?
          • For example, let’s say I want to run a script that requires 3 variables as input, but rather than prompting for the values I wish to read them from the script file name
          • e.g., the file name might be “Myscript.js (my_variable1, my_variable2, my_variable2)” … where variables are all real numbers.
          • So I assume the script name when run should look something like Myscript.js (10, 10, 100), but how do I then read these and assign these values to a var statement within the script?

           

          If I understand properly, how about something like this?

           

          /*
          Using a file name like: myScript_10_50_100_.js
          The following script snippet will pull out
          the numbers and make them variables
          */
          var jsFile = new File($.fileName);
          var scriptName = jsFile.name;
          alert("Script File Name"+"\r"+scriptName);
          var numberVars = scriptName.replace( /^\D+/g, '');
          var variableArray = numberVars.split('_');
          var var1 = variableArray[0];
          var var2 = variableArray[1];
          var var3 = variableArray[2];
          alert("Variables:"+"\r"+"var1 = "+var1+" , var2 = "+var2+" , var3 = "+var3);
          
          • 2. Re: Read input parameters from a script file name
            Willis77019b Level 1

            W_J_T

            Excellent! I am very grateful for your help.

            • 3. Re: Read input parameters from a script file name
              W_J_T Level 4

              You're welcome, glad it was helpful, I am thankful for your gratefulness.

              • 4. Re: Read input parameters from a script file name
                msfriday

                Hello,

                 

                I don't know anything about Javascript, except that it exists lol

                 

                I saw this thread and I would like to know if this answer applies to what I want to accomplish.

                 

                I want to create a zodiac compatibility 'thing' (I don't know if I should call it a form OR quiz? - but I want it to have two drop downs, a submit button, and then a response to appear)

                I want this on my wordpress site if possible, but if it has to be an html site without wordpress okay...... and I would like to be able to embed, or iframe it onto relationship forum threads..... Thank you in advance if you are able to reply!

                java for ZODIAC.jpg