• No results found

And(a, b) a&b

Description Logical And.

Returns

1 (true) if both a and b are true.

0 (false) if either a or b is false or if both a and b are false.

Missing if either a or b is a missing value or if both a and b are missing values.

Arguments

Two or more variables or expressions.

Notes

More than two arguments can be strung together. a&b returns 1 (true) only if all arguments evaluate to true.

See Also

The Conditional Expressions and Loops section of the Scripting Guide.

AndMZ(a, b) AndV3(a, b) a:&b

Description

Logical And with JMP 3 behavior, which treats missing values as 0.

Returns

1 (true) if both a and b are true.

0 (false) if either a or b is false or if both a and b are false.

0 (false) if either a or b is a missing value or if both a and b are missing values.

Arguments

Two or more variables or expressions.

62 JSL Functions Chapter 2

Conditional and Logical Functions JSL Syntax Reference

Notes

More than two arguments can be strung together. a:&b returns 1 (true) only if all arguments evaluate to true. When opening a JMP 3 data table, this function is automatically used for any And function.

See Also

The Conditional Expressions and Loops section of the Scripting Guide.

Break()

Description

Stops execution of a loop completely and continues to the statement following the loop.

Note

Break works with For and While loops, and also with For Each Row.

Choose(expr, r1, r2, r3, ..., rElse) Description

Evaluates expr. If the value of expr is 1, r1 is returned; if 2, the value of r2 is returned, and so on. If no matches are found, the last argument (rElse) is returned.

Returns

The value whose index in the list of parameters matches expr, or the value of the last parameter.

Arguments

expr an expression or a value.

r1, r2, r3, ... an expression or a value.

Continue() Description

Ends the current iteration of a loop and begins the loop at the next iteration.

Note

Continue works with For and While loops, and also with For Each Row.

For(init, while, increment, body) Description

Repeats the statement(s) in the body as long as the while condition is true. Init and increment control iterations.

Returns Null.

Chapter 2 JSL Functions 63

JSL Syntax Reference Conditional and Logical Functions

Arguments

init Initialization of loop control counter.

while Condition for loop to continue or end. As long as the conditional statement while is true, the loop is iterated one more time. As soon as while is false, the loop is exited.

increment Increments (or decrements) the loop counter after while is evaluated every time the loop is executed.

body Any number of valid JSL expressions, glued together if there are more than one.

Example

If(condition, result, condition, ..., <elseResult>) Description

Returns result when condition evaluates true. Otherwise returns next result when that condition evaluates as true. The optional elseResult is used if none of the preceding conditions are true. If no elseResult is given, and none of the conditions are true, then nothing happens.

IfMax(expr1, result1, expr2, result2, ... <all missing result>) Description

Evaluates the first of each pair of arguments and returns the evaluation of the result expression (the second of each pair) associated with the maximum of the expressions. If more than one expression is the maximum, the first maximum is returned. If all expressions are missing and a final result is not specified, missing is returned. If all expressions are missing and a final result is specified, that final result is returned. The test expressions must evaluate to numeric values, but the result expressions can be anything.

Returns

The result expression associated with the maximum of the expressions

IfMin(expr1, result1, expr2, result2, ... <all missing result>) Description

Evaluates the first of each pair of arguments and returns the evaluation of the result expression (the second of each pair) associated with the minimum of the expressions. If more than one expression is the minimum, the first minimum is returned. If all expressions are missing and a final result is not specified, missing is returned. If all expressions are

64 JSL Functions Chapter 2

Conditional and Logical Functions JSL Syntax Reference

missing and a final result is specified, that final result is returned. The test expressions must evaluate to numeric values, but the result expressions can be anything.

Returns

The result expression associated with the minimum of the expressions

IfMZ(condition, result, condition, ..., <elseResult>) IfV3(condition, result, condition, ..., <elseResult>)

Description

Logical If with version 3.x behavior, which treats missing values as 0; used automatically when opening v3 data tables.

Interpolate(x, x1, y1, x2, y2) Interpolate(x, xmatrix, ymatrix)

Description

Linearly interpolates the y-value corresponding to a given x-value between two points (x1, y1), and (x2, y2) or by matrices xmatrix and ymatrix. The points must be in ascending order.

Match(a, value1, result1, value2, result2, ...) Description

If a is equal to value1, then result1 is returned. If a is equal to value2, result2 is returned, and so on.

MatchMZ(a, value1, result1, value2, result2, ...) MatchV3(a, value1, result1, value2, result2, ...)

Description

Match with version 3.x behavior, which treats missing values as 0; used automatically when opening v3 data tables.

Not(a)

!a

Description Logical Not.

Returns

0 (false) if a>0.

1 (true) if a<=0.

Missing value if a is missing.

Chapter 2 JSL Functions 65

JSL Syntax Reference Conditional and Logical Functions

Argument

a Any variable or number. The variable must have a numeric or matrix value.

Notes

Mostly used for conditional statements and loop control.

See Also

The Conditional Expressions and Loops section of the Scripting Guide.

Or(a, b) a|b

Description Logical Or.

Returns

1 (true) if either of or both a and b are true.

0 (false) otherwise.

Missing if either are missing.

Arguments

a, b Any variable or number.

Notes

Mostly used for conditional statements and loop control.

See Also

The Conditional Expressions and Loops section of the Scripting Guide.

OrMZ(a, b) OrV3(a, b) a :| b

Description

Logical Or with version 3.x behavior, which treats missing values as 0.

Returns

1 (true) if either of or both a and b are true.

0 (false) otherwise.

Arguments

a, b Any variable or number.

66 JSL Functions Chapter 2

Constants JSL Syntax Reference

Notes

Mostly used for conditional statements and loop control. When opening a JMP 3 data table, this function is automatically used for any Or function.

Or() returns missing if any evaluated argument is missing. OrMZ() returns 0 if any evaluated argument is missing.

See Also

The Conditional Expressions and Loops section of the Scripting Guide.

Step(x, x1, y1, x2, y2, ...) Description

Finds corresponding y for a given x from a step-function fit. The points must be in ascending order.

Stop()

Description

Immediately stops a script that is running.

While(expr, body) Description

Repeatedly tests the expr condition and executes the body until the expr is no longer true.

Constants

JMP provides functions for two useful constants.

Note: These functions do not take an argument, but the parentheses are required.

e()

Description

Returns the constant e, which is 2.7182818284590451...

Pi( )

Description

Returns the constant π, which is 3.1415926535897931...

Chapter 2 JSL Functions 67

JSL Syntax Reference Date and Time Functions