Script windows are typically distinguished by their file extension of .ijs. Note that this extension is not required - in fact any file that does not have an extension of .ijx is treated as a script window. However, it is good practice to use .ijs for any file intended as a J script.
When you create new script windows, the names used are 1.ijs, 2.ijs and so on. By default, 1.ijs is used, however if a file of this name already exists, the next available unused name is picked.
You can type sentences into a script window, but these are not evaluated. When you press Enter, the cursor is simply moved to the line below. To run a script window, you can either select an execution window and then enter a sentence to load the corresponding script file, or you can run it directly by selecting one of the options from the Run menu or pressing the equivalent Ctrl key:
Window | Ctrl+W | runs script window |
Selection | Ctrl+E | runs selected text only |
Line | Ctrl+R | runs current line only |
File | Ctrl+T | runs a script file, selecting from the File/Open dialog box |
By default, these options are run silently - script output will only display if there is an error. To run the options with display on, hold down the Shift key when you click on the menu option, or press Shift-Ctrl-key.
When you select the Run/Window menu option, the session manager first saves the script as a file (if changes have been made), then loads this file into the most recently active execution window. In some cases, you do not have to switch to the execution window at all - for example if you are developing a Windows application, then you can create and test the parent and child controls directly from the script window.
You can open as many script windows as you wish - all are attached to the same session.
The script windows 1.ijs, 2.ijs and so on represent temporary files. That is, while the session is active, if you have a window 2.ijs then there is a file of that name (temp\2.ijs), but when you close the window or terminate the session, you are prompted for the file to be deleted. You can save these files if you wish with the same name, but when you load them again, they are still treated as temporary and you will again be prompted to delete them when they are closed.
If you explicitly save them with a name other than n.ijs, for example, mywork.ijs, then the J session manager treats them as permanent files. If you close a permanent file or terminate the J session, you are prompted to save the file, if it has been changed. You are also prompted to save the file when you first save changes to a permanent script file that you have loaded in a session (which may be when you run it as a script).
Prompting for script windows is therefore as follows: