14.03.2014 Views

Scripting Guide - JMP

Scripting Guide - JMP

Scripting Guide - JMP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 2 JSL Building Blocks 33<br />

The JSL Language<br />

Names<br />

A name is exactly what you think: something to call a thing. For example, when you assign the numeric<br />

value 3 to a global variable in the statement a=3, “a” is a name. Commands and functions have names,<br />

too. In the statement Log(4), the word “Log” is the name of <strong>JMP</strong>’s logarithm function. A name is any<br />

language token that isn’t a number or a string or a special symbol operator (such as + or – or ++ or ^).<br />

Names have a few rules:<br />

• Names must start with an alphabetic character or underscore, and can continue with those as well as<br />

numeric digits, spaces, tabs, vertical tabs, line and page delimiters, double-byte characters,<br />

apostrophes, percent signs, periods, and backslashes:<br />

a-z A-Z 0-9 _ ‘ % . \<br />

• When comparing names, the white-space characters (like blanks, tabs, and newlines) are ignored,<br />

and upper and lower case is not distinguished. For example the names Forage and for age are<br />

equivalent.<br />

2 JSL Building Blocks<br />

Why does the language allow blanks inside names? Because it is good to have names of<br />

commands and options be the same in the language as they are on the menus and<br />

dialogs, and because people think in terms of multi-word names. The price of allowing<br />

blanks is that JSL needs more delimiters, specifically commas and parentheses.<br />

• Actually, you can still have a name that is any other sequence of characters, but if it doesn’t obey the<br />

rules above, it needs to be quoted and placed inside a special parser directive called Name( ). For<br />

example, to have a global variable with the name -)(*$%(*&$%A, you have to put it inside<br />

quotation marks and Name( ) every time you use it in JSL:<br />

Name("-)(*$%(*&$%A")=42;<br />

foo=4; print(foo+Name("-)(*$%(*&$%A"));<br />

46<br />

Name is harmless when it isn’t needed; for example, foo and Name("foo") are exactly the same<br />

thing.<br />

Numbers<br />

Numbers can be written as integers, decimal numbers, in scientific notation with an E preceding the<br />

power of ten, and as dates, times, or date/time values. A single period by itself is the missing numeric<br />

value (sometimes called NAN for “not a number”).<br />

For example, these are all numbers:<br />

. 1 12 1.234 3E3 0.314159265E+1 1E-20<br />

If you precede a number with a minus sign, the minus sign is usually interpreted as a prefix operator,<br />

not part of the number. You can follow a number immediately with an E followed by a power of ten<br />

you want to scale the number by. For example 3E2 means 3 times 10 to the power 2, or 300. If you<br />

need a negative exponent of ten in E notation, that minus sign is part of the number.<br />

Dates and times<br />

<strong>JMP</strong> supports date/time values in a variety of common date/time notation formats. Date/time values are<br />

stored and computed as a number of seconds since midnight, January 1, 1904. However, you can enter<br />

a date/time value literally, using the format ddMonyyyy:hh:mm:ss.ddd, as in:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!