- 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; var var2 = variableArray; var var3 = variableArray; alert("Variables:"+"\r"+"var1 = "+var1+" , var2 = "+var2+" , var3 = "+var3);
Excellent! I am very grateful for your help.
You're welcome, glad it was helpful, I am thankful for your gratefulness.
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!