Script Editing Window

These windows allow one to edit scripts. For a list of available commands see Script Commands; for general information about scripts see About scripts. Several basic editing functions are available in the window. Text can be selected with the mouse. Text can be cut with Ctrl X, copied with Ctrl C, and pasted with Ctrl V. Ctrl Z will undo the last action. While you are editing a script, the text in the window will not match the version of the script stored in the program. However, running the script, closing the editing window with the OK button, switching the editing window to another script, or even exiting the program will transfer the text in the window to the program's memory.

The buttons above the text area can be used to switch the Editor window to the next or previous available script, or to shift the current script down or up in the list of scripts.  Specifically:

Left and Right Editor buttons - Switch the editor window to the previous or next script that is not already open in an editor.

Up and Down Script buttons - Shift a script in the list of scripts; i.e., swap it with the previous or next numbered script.  'Up' and 'down' here refer to the vertical position of scripts in the menu and toolbar.  The window will stay with the current script and change its number.  If the adjacent script is also open in an editor, both windows will change.  These buttons can be disabled unless in Administrator mode with the property 'ShiftScriptOnlyInAdmin'.

Indentation Buttons - This row of buttons is useful for scripting in Python; they can be hidden with the Show Indent Buttons command in the script menu.

Indent - Fix - Re-indent the selected set of lines as if Tab or ` was typed on each line from the beginning to the end.

Indent - Increase - Add one unit of indentation (the indent size) to all of the selected lines.

Indent - Reduce - Remove one unit of indentation from all of the selected lines if possible.  If any lines are indented by less than one unit, nothing will be done.

Completions, Arguments Lists, and Auto-indenting - Below these buttons is a line of text that starts out with a reminder that you can use Tab or ` (the back-tick character) to automatically complete a command name (the first word on a line) as well as convert it to a standard mixed-case form.  Tab may not work on non-US keyboards, but ` always will.  When you start editing in a window, this line will list up to 10 possible completions of the current text as you type a command.  Only a few will show up at the default window size; make the window wider to see more completions. 

When the command is completed, or when you type Tab or ` in the middle or at the end of a command name, the program will use the completion line to show the summary of command arguments from the script help file.

Another consequence of typing Tab or ` anywhere on the line is that the editor will set the indentation of the current line based on the indentation of the previous line, whether the previous line starts a block (i.e., with If, Else, Elseif, Loop, or Function), whether the current line ends such a block, and whether it is a continuation line.  The amount of additional space in a block or for continuation lines can be controlled with the Set Indent Size command in the Script menu.

Behavior for Python scripts - If a script starts with "#!Pyth", the editor scans the start of the script to see how Serialem script functions should be prefixed, stopping at the first non-blank line that is neither a comment nor an import line.  If it encounters either a line importing serialem, or a '#serialemPrefix' line specifying the prefix, that determines what prefix it expects to find before commands: either no prefix if you import as 'from serialem import *', prefix 'serialem' if you use 'import serialem', or the alias if you import with an alias, such as 'import serialem as sem'.  When you type the completion character, it looks back to the beginning of the word to see if there is already a namespace prefix.  If so, and it does not match the expected prefix, it will not attempt to complete the word, just manage indentation.  If it does match or is not present, then it will try to complete the word unless it is a Python keyword, and insert the prefix if appropriate.  For example, if you use 'import serialem' and type the completion character after 'choo', it will insert 'serialem.ChooserForNewFile'.

Completion works both at the beginning of the line and for a word after an '='.

Indentation will follow the indentation of the previous line, adding a unit of indentation if that line ends in ':'.  However, there is no way for it to tell in general when to remove indentation, as there is with regular scripting.  One mildly helpful feature is available if you leave a blank line after the end of a block.  Typing the completion character more than once will make it toggle between the indentation of the previous line and one less unit of indentation. 

A controllable way to remove one unit of indentation at a time on any line is to hold down the Shift key while typing the completion character.  This allows you to close a block without a blank line or close more than one block.  The 'Indent' buttons at the bottom of the editor should also be helpful.

The buttons below the text area perform the following functions:

Run - will save the script in program memory and run it.  Pressing Ctrl-Enter within the editing window will also run the script.

Cancel - will close the window without saving the most recent changes in program memory.

OK - will save the script in program memory and close the window.

Load - will allow you to read a script from a file into the current script. Once a script has been read from a file, the Save button will save it back to that file.

Find - will search for text in the script.  An entry box will open for the text to find.  The search is case-insensitive.

To Line - will allow you to enter a line number to go to.  After an error in a Python script, the default value i nthe entry box will be line with the error.  The cursor will be moved to the specified line, the window will be scrolled, and the first three characters on the line will be selected to make it more visible. 

Save - will allow you to save this script to a text file. If you have saved it to a file before, or if you loaded it from a file, it will be saved to the same file. Otherwise you will enter the Save As dialog box to specify a file

Save As - will allow you to save this script to a different file via the Save As dialog box.