cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
The Script Window - Basics
 

The script window contains several interesting features of which new users may not be aware. This recipe introduces you to some.


Ingredients:
  • Script Editor
  • Scripting Index
  • Enhanced Log

Difficulty – Very Easy

Video Length – 3:40

Steps:
  1. Open both the log (Windows: View > Log, Mac: Window > Log) and a new script window (File > New > Script, Mac: File > New > New Script). Type the following line into the script window:
    num1 = 16;

    Run the script by selecting Run Script from the Edit menu. Make sure nothing is selected before you do this. Scripts can also be run using the Run Script button on the Script Editor window or using the shortcut key sequence CTRL-R (Mac: Command-R).

  2. Type the following line and select it
    NUM 1 = 3.1459;
    You can limit the code that gets executed by first selecting it. This can be applied to individual words, an entire line, or multiple lines. Run the script with the line selected.
  3. The result you see in the log for num1 and NUM 1 are identical. This is because JSL ignores both case and whitespace, making the two variable names identical.
  4. The following line shows how JSL represents numbers in scientific notation:
    Print(6.022e+23,1.38E-23,3E108)
    Values larger than 1.8E308 are set to missing.
  5. For JMP 15 and later, line numbers will appear on the left of the script window. Certain JSL elements are colored. Built in functions are medium blue, text strings purple and number teal. Typing an open parenthesis immediately produces a matching close parenthesis. These are all default behaviors of the Script Editor window and can be altered through the Preferences.
  6. Missing values are shown as an unquoted period. This code illustrates that they are treated as numbers
    Type(.)

    The Type function returns the data type of its argument.

  7. Hover over Type and move the cursor up and down slightly. Pop-up help for the function will appear. Hover over num1 and move the cursor. A pop-up shows the value stored in it.
  8. Hover over Type again and right click. Select Help > Scripting Index. The scripting index will open with this function displayed.
  9. Making sure the log is visible, run the next two lines of code. Use ESC to stop execution.
    i = 1;
    While(1,Print(i++));
  10. Anything appearing after two backslashes (//) is commented out of the code. This continues until the end of the line. Anything appearing after backslash asterisk (/*) is commented out of the code until an asterisk backslash (*/) appears.

Hints for Success:

  • Open the Enhance Log window before executing any code
  • JSL ignores white space in variable names. Names are not case sensitive.
  • The unquoted period is a missing numeric value.
  • Hovering over a function produces pop-up help. Right-clicking over a function opens the Scripting Index for that function.
  • Hovering over a variable shows the value stored in the variable.
  • ESC stops a running script.