The Script Window - Basics
Created:
Feb 23, 2022 03:14 PM
| Last Modified: Mar 30, 2022 9:00 AM
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:
- 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).
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Hover over Type again and right click. Select Help > Scripting Index. The scripting index will open with this function displayed.
- Making sure the log is visible, run the next two lines of code. Use ESC to stop execution.
i = 1;
While(1,Print(i++));
- 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.