How can you use Global Variables with Encrypted ScriptsUsing an encrypted script in Jmp13, I would like to read up a pre-assigned global variable.
Example:
With a standard script assign...
a=0;
b=10;
Using an Encrypted script
if (IsEmpty(a)==1,a=5); // DO NOTHING IF ITS NOT EMPTY
if (IsEmpty(b)==1,b=50); // DO NOTHING IF ITS NOT EMPTY
Write(a);
Write(b);
Goal: If the global variable is undefined, assign it in the encrypted script. If the global variable is defined, use the defination.
It works without encryption. Also, after executing the encrypted script, I can see the assigned defaulted globals.
So, is it possible to use a global variable with an encrypted script?
Thanks for the help.
Re: How can you use Global Variables with Encrypted ScriptsWell, you and @Craige_Hales are right that unchecking the "Use the Here namespace..." option in the add-in builder will resolve your specific issue.
However, I'm sure that @Craige_Hales would agree with me that the better programming/scripting practice is to properly scope all variables as you reference them.
The "Use the Here namespace..." option is on by default in order to protect the global namespace from accidental corruption.
Re: How can you use Global Variables with Encrypted ScriptsJeff, thanks for the confirmation. Yes, I agree. It's a scoping issue. However, the solution is to uncheck that box in the add-in. This allows the outside script to set a global, and the internal add-in to use it. I wish I could have found that in one of the guides. Oh well.Re: How can you use Global Variables with Encrypted ScriptsI think this will get you close to the answer; it looks like the default is to use the Here namespace in an addin, so you might need to use global:a rather than a
checked by defaultchecked by defaultchecked by default
Re: How can you use Global Variables with Encrypted ScriptsANSWER ==> Un click the "Use the "Here" namespace for unqualified JSL variable names
It works for standard add-in script and for encrypted scripts.
Un select: Use the "Here" namespaceUn select: Use the "Here" namespaceUn select: Use the "Here" namespace
Re: How can you use Global Variables with Encrypted ScriptsI believe this is an issue of scoping and namespaces, and the fact that the add-in menu uses Names Default to Here(1).
If you're trying to reference variables you should always use a scoping operator to reference them. The scoping operator for global variables is ::.
names default to here(1);
::a=0;
a=45;
if(::a==0, show("yes"));
if(here:a == 45, show("yes"));Re: How can you use Global Variables with Encrypted ScriptsFurther Clarification: The issue is not with encryption, but with the add-in. Using the jsl directly in the add in causes the same issue. The global variables are not seen by the add-inRe: How can you use Global Variables with Encrypted ScriptsClarification. The issue lies within using the encrypted script in an add-in.
Just confirmed that it works with encryption as a stand alone script.
So does the add-in operate on a different variable space? Odd, as I can see other variables from encrypted scripts in this add-in
Apologies for not debugging this completely.