cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

Creating Variables

Started ‎11-08-2022 by
Modified ‎11-08-2022 by
View Fullscreen Exit Fullscreen

OK, so let's look at a few examples of creating variables. Suppose you want to create a variable named a, and you want to assign the value of to it. This assignment statement (a = creates a global variable with the value of What if you want a local variable named a? To create a local variable, you use the Local function, which takes two arguments: the first argument is a name or list of names for the local variable or variables, and the second is a JSL expression that's evaluated in the local context. And you can either initialize the values of the local variables in the list of names or as part of the JSL expression. So in this example, the variable a is assigned a value of in the Local function. Any calculation performed with a in that local block would use the value of but after that portion of the script has run, the global variable a would still be storing the value of Now, suppose the first line in your script is the Names Default to Here call, with the Boolean one as its argument. If you assign a value of to after that call, then the assignment statement creates a variable named a in the Here namespace. This version of the variable a can be used anywhere within that same script, but the global version of a is still storing the value Remember that the double colon prefix is the scoping operator for a global variable. So you can use it when you create a global variable, and when you want to refer to an existing global variable. If you're working in the global namespace, the double colon scoping operator isn't required, but it is recommended as a best practice. And if needed, you can use the scoping operator to create or refer to global variables even in scripts that use the Here namespace. JMP provides several functions to help you manage your variables. You can determine the current set of global variables and their associated values by calling the Show Globals function. You can clear the values of all global variables or of specific global variables by calling the Clear Globals function. This sets those values to missing, but the names will remain in the namespace. You can prevent changes to global variables by calling either the Lock Globals or Lock Symbols function, and then you can allow changes to previously locked global variables by calling either the Unlock Globals or Unlock Symbols function. Finally, you can remove all global variables, or just specific ones, from the global namespace entirely by calling the Delete Globals function.