turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Re: The difference between glue and if

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Tuesday
(108 views)

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

Thanks a lot!

4 REPLIES

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Tuesday
(93 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Wednesday
(59 views)

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Tuesday
(92 views)

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.

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Wednesday
(57 views)

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