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

The difference between glue and if

Could someone gives me some insprision about the differences between glue and if in jmp? I got so confused.

 

Thanks a lot!

4 REPLIES 4
txnelson
Super User

Re: The difference between glue and if

An "If()" function has the structure of:

If( condition,
     run this if the condition is true
,
     run this if the condition is false
)

An example would be

If( :sex == "F",
     Show("This is a Female")
,
     Show("This is a Male")
)

Now, where a "Glue" character comes into play, is if in the true or false sections, more than one statement needs to be executed, the statements need to be "Glued" together to show that the true or false section one complete item.  So if both: Show("This is a Female") and Gender = "Female" needs to be executed you need to "Glue" the statements together

If( :sex == "F",
     Show("This is a Female");
     Gender = "Female"
,
     Show("This is a Male")
)
Jim

Re: The difference between glue and if

Thank you so much Jim! It is so helpful for me!

Jeff_Perkinson
Community Manager Community Manager

Re: The difference between glue and if

Glue() and If() are – almost – completely unrelated, so it's hard to compare them.

 

Glue

In all honesty, you can ignore Glue() and be a very successful JSL programmer. So, if this confuses you, don't worry about it.

 

JSL is a functional language. That is, everything(ish) in JSL is a function. Some functions in JMP have operator forms.

 

For example, the function to assign a value to a variable is Assign(a, b), which assigns the value of b into a. There is an operator form of that using an = sign:

a=b

 

The function that puts expressions together into something that can be evaluated is Glue(), as in:

 

Glue(Assign(a,b), Add(c,d))

 

The operator form of Glue() is a semicolon (;), the following is the equivalent of the above:

 

Assign(a,b);
Add(c, d)

If

In any programmming language you need constructs to make decisions. In JSL, as in other languages, these are condtional functions

 

If() takes at least three arguments:

  • a condtional
  • true result
  • else result

I find it easiest to understand If() by looking at it's prototype in the Formula Editor.

JMPScreenSnapz225.png

Notice the first "expr" there. That's the condition to be tested and it's the first argument. The second argument, the "then clause", is the expression that should be evaluated if the condition is true. The third argument is the "else clause," the expression to be evaluated if the condition isn't true.

 

Outside of the formula editor this looks like:

If( a == "some value",
	Show( "True" ),
	Show( "False" )
);

So, this tests the condition that a is equal to "some value" and shows "True" if it is and "False" if it isn't.

 

Each of the clauses can contain multiple statements, separated by semicolons (;).

 

I hope this helps clear up some confusion.

 

If you've got more questions, let us know.

 

-Jeff

Re: The difference between glue and if

Thank you so much Jeff! Your answer gives me a clear picture of how to use JMP in the future!