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

Working with Expressions

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

Expressions are an important concept, and an integral part of the JMP scripting language. But what is an expression? Well, it's a section of JSL code that accomplishes a task. JSL expressions hold data, manipulate data, and send commands to objects. An expression can be defined as any combination of variables, constants, and functions or operators that can be evaluated. It might be as simple as a number or a variable name. Or, it could be an entire script. You can store an expression in a variable, and JMP always evaluates expressions immediately. Now, in some cases, you might want to delay the evaluation of an expression. Delaying evaluation lets you examine or change the expression before JMP evaluates it. So you use the Expr function to delay evaluation of an expression, with the expression itself being the only argument, and the function returns the unevaluated expression, which can be stored in a variable. This is also referred to as quoting the expression. The corresponding action to delaying evaluation of an expression is evaluating that expression. You use the Eval function to immediately evaluate the expression, with the expression, or a variable storing it, as the only argument. And this function returns the result of evaluating the expression. This is referred to as unquoting the expression. Sometimes, you need to access a quoted expression without evaluating it. You can retrieve an expression without evaluation by using the Name Expr function, which returns the unevaluated expression. So, for example, suppose you use the Expr function to store the expression times in the variable a. The expression is stored unevaluated and returned to the log. If you use the variable a in your script, JMP will evaluate the expression it's storing. If you need to access the literal expression stored in a without evaluating it, you use the Name Expr function with a as its argument. OK, so now that you know how to delay the evaluation of an expression, let's talk about why you might want to do that. One reason is so that you can modify the expression. You can change expressions through insertion, removal, or substitution, just like with lists. And there are many functions that take expressions as arguments and change them. For example, suppose you assign to the variable a. You can use the Insert Into function to modify that expression. by adding an argument to it. For example, if you want to add a factor of to the expression, you'd use the Insert Into function and specify a as the first argument and as the second argument. Then, is inserted into the Multiply function, and the expression stored in a becomes times times