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.
Sorry for the ignorance, and thanks fro the help man! i really appreciate it.
It's quite easy. Let's say you have 2 folder-level scripts: script1.js and
In the former you have this code:
var a = "Hello";
And in the latter you have this code:
When you open the application you should see an alert window that says
Now, there could be some issues related to scope and the order in which the
scripts are loaded, but that's the basic concept.
Like in a function
... 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.
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.
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.
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?
1 person found this helpful
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.
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.