Script menu commands
The Script menu offers the following commands for controlling scripts:
|Edit||Opens a submenu for opening script editors|
|Edit 1, 2, ...||Opens a window for editing a script.|
|Run||Opens a submenu for running scripts.|
|Run 1, 2, ...||Runs a script.|
|Edit/Run One Line...||Opens window to allow up to 5 one-line scripts.|
|Keep Focus on One Line...||Toggles whether keyboard focus returns to One-Line Script window after script runs.|
|Stop||Stops script at next command.|
|End||Stops script at end of loop or repeat.|
|Resume||Resumes script at place where it stopped.|
|Toolbar||Opens a toolbar with buttons for all scripts.|
|Set Height||Sets the number of buttons and button height in the script toolbar.|
|Set Cam Panel Rows||Sets the number of rows of script buttons in the Camera & Script control panel.|
|Controls||Opens dialog box to set conditions for stopping a script.|
|Load New Package...||Loads all scripts from a file and makes that file be the current package.|
|Save Package||Saves all scripts to the current package file.|
|Save Package As||Saves all scripts to a new file and makes that the new current package.|
|Load Many||Loads all scripts in a file into their given script numbers.|
|List Functions||Lists all functions defined in scripts.|
|List Persistent Vars||Lists all persistent variables defined by scripts in the log window.|
|Clear Persistent Vars||Clears all persistent variables defined by scripts.|
|Set Indent Size||Sets number of spaces for automatic indenting in editor.|
|Show Indent Buttons||Toggles whether to show buttons for adjusting indentation of lines in editor.|
|Use Monospaced Font||Toggles whether to use an equally spaced font in the editor.|
|Set # of Status Lines||Sets the number of status lines displayed in the Camrea & Script panel.|
|Monospace Status Lines||Toggles whether to use an equally spaced font in the status lines.|
|Run at Program Start...||Toggles whether to run a script on program startup and lets you select script|
|Run at Program End...||Toggles whether to run a script on program exit and lets you select script|
|Run if Program Idle...||Toggles whether to run a script periodically when the program is idle and lets you select script and time interval|
|Open Editors on Start||Toggles whether editing windows will be restored on program startup.|
|Verbose||Toggles echoing of each line at start of script.|
For a list of available script entries, see Script Commands; for general information about scripts see About scripts.
Edit command (Script menu)
Use one of these commands to open a Script Editing Window for editing the given script. Use the left or right 'Editor ' arrows in the editing window to get to scripts numbered higher than 10. You can also open an editor for an existing script by clicking with the right mouse button on a button for the script in the Script Toolbar or in the Camera & Script Control Panel, or by holding down the Ctrl key and pressing as usual with the left mouse button.
Run commands (Script menu - Run submenu)
Use one of these commands to run a selected script. There is an entry for all of the currently available scripts.
Edit/Run One Line command (Script menu)
Use this command to open a small free-standing window in which you can enter a set of one-line scripts and run them. As of SerialEM 4.1, 30-Mar-23, 'one-line' no longer means 'one command'. Multiple commands can be entered, separated by ';' (semicolon). The window allows up to 5 such scripts. When you edit in one of the lines, its Run button becomes the default button for the window (as shown by the Run being in bold) and pressing Enter (Return) will run that script. This window is resizable, so you can change the height to show just the number that you need, or change the length to accommodate longer entries. The lines are preserved between sessions in the settings file. The first time that you open the window, it will show one text box; subsequently it will restore its previous size and location.
Command completion with tab or ` works in this window just as in a regular script editor. In addition, Ctrl-A will select the whole line, after which it can be deleted with the Delete key, or the whole line can be deleted with Ctrl-U. Ctrl-Z can be used to undo the last operation. Ctrl-X, Ctrl-C, and Ctrl-V also work for cut, copy, and paste. Up and down arrows can be used to jump to the line above or below. When a script is done, focus will return to the text box of the script that was run, so you can easily change it and run again, or move to another script with an arrow key and run that. The Escape key will return focus to the main program, without closing the window, so that other keyboard commands can be used. The focus can be kept from returning by turning off the next option.
Keep Focus on One Line command (Script menu)
Use this command to toggle whether keyboard focus returns to the line of the one-line script that is run.
Stop command (Script menu)
Use this command to stop a running script.
End command (Script menu)
Use this command to stop a running script at the end of a loop or the end of the script (before repeating). In addition, when a script is run from the Navigator, the End command can be used while the script is stopped to terminate that script and let the Navigator go on to acquire at the next point.
Resume command (Script menu)
Use this command to resume a script that was stopped with the Stop or End command. If you want to start a script from the beginning, run it rather than resuming it. The next command in sequence will be executed if you stopped with End. If you stopped with STOP, the program will show you the line that it stopped on and ask whether you want to redo this command or go on to the next. In some cases a script that stops because of an error condition can be resumed from the point at which it stopped; the program will resume from either the current or next command as appropriate for the type of error.
Toolbar command (Script menu)
This command opens a small panel with buttons for all scripts, or as many are specified with the Set Length command. The buttons are wide enough to allow somewhat longer script names than in the Camera & Script Control Panel. Individual buttons will be enabled when a script is available to run or when it is open in an editing window. You can open an editor window for any existing script by holding down the Ctrl key while pressing the button. If you lose the toolbar behind other windows, invoke this menu command again to raise it. The program will remember this window's position and whether it is open between sessions.
Set Height command (Script menu)
Use this command to set the number of buttons in the script toolbar, and their height in pixels. Initially, the toolbar will have 10 buttons. The button height can be increased if the buttons seem too narrow to select reliably, or decreased to fit more buttons on the screen. Enter a height of 0 to return to the initial height. The spacing between buttons may also be decreased when the height is decreased, especially when
Set Cam Panel Rows command (Script menu)
Use this command to set the number of rows of script buttons and spinners in the Camera & Script control panel. It is possible to have up to 12 buttons in 4 rows. Enter a value between 1 and 4.
Controls command (Script menu)
Use this command to open the Script Controls dialog box in order to set conditions for stopping a script. The script can be stopped when the stage reaches a certain tilt angle, image intensity falls below a certain level, image shift exceeds a certain amount, montage error is too large, or the script has repeated a given number of times.
Load New Package command (Script menu)
Use this command to load a package of scripts from a file and make that file be the 'current script package file', which is loaded and saved along with the settings file. As of SerialEM 3.8, scripts are no longer saved in the settings file but in a separate file, with the name of that file saved in the settings file. This means that you can have multiple packages of scripts without having to store them in different settings files, and also that you can have multiple settings files all using the same scripts. You will be asked whether you want to save the current package first, in case it has changed. If a script is empty in the newly loaded package, an existing script in that position will be cleared out.
Save Package command (Script menu)
Use this command to save all scripts, including one-line scripts, to the current package file.
Save Package As command (Script menu)
Use this command to save all scripts to a new file, which becomes the current package file whose name is saved with the settings.
Load Many command (Script menu)
Use this command to load multiple scripts from a file and place them into their respective script numbers, leaving any other existing scripts unchanged and not changing which file is considered the current script package. These scripts must have been saved so that each one starts with a line with 'Macro' and the script number, and ends with the line 'EndMacro'. This is the way scripts were stored in settings files and now in script package files, so this command can be used to read only the scripts from a settings file. However a single script saved from the editing window cannot be read with this command because it does not have these starting and ending lines.
List Functions command (Script menu)
Use this command to get a list in the log window of all functions defined in all scripts. The function name will be followed by the number of arguments and 0 or 1 for whether it takes a string argument.
List Persistent Vars command (Script menu)
Use this command to get a list in the log window of all currently defined persistent variables.
Clear Persistent Vars command (Script menu)
Use this command to clear all of the persistent variables that have been defined by previously run scripts. This will make a stopped script non-resumable.
Set Indent Size command (Script menu)
Use this command to set the number of spaces that the script editor will use for auto-indenting when Tab or ` (the back-tick character) is typed. This spacing is added at the first line of a block starting with IF, LOOP, ELSE, or Function, and taken away when such a block ends. Enter 0 to prevent auto-indenting.
Show Indent Buttons command (Script menu)
Use this command to toggle between showing and hiding the three buttons at the bottom of the editor window for adjusting indentation in selected lines. The change will not take effect until you resize or reopen windows. These buttons were added to help with scripting in Python but could be useful for regular scripting too.
Use Monospaced Font command (Script menu)
Use this command to toggle between using the regular proportional font and an equally-spaced font in all editor windows. If it is grayed out, it means that no monospaced font was available. The program tries to access Lucida Console, Consolas, and Lucida Sans Typewriter, and if those fail it tries to use Courier New with a heavier weight. However, it cannot tell if the system is going to use a Courier font even though it asked for a better one. If you get a font you do not like, add the property 'ScriptMonospaceFont' with the exact name of a monospaced font available on your system, which it will try first..
Set # of Status Lines command (Script menu)
Use this command to adjust the number of status lines visible at the bottom of the Camera & Script control panel. These lines are written to with the 'SetStatusLine' script command, and the number of lines is always set so that the line being written will be displayed. Thus, this setting can be changed by that command, and this menu entry allows one way to close up the lines, the other being a script command 'SetUserSetting NumStatusLines 0 1'. Enter a value from 0 to 6, the current maximum.
Monospace Status Lines command (Script menu)
Use this command to toggle whether the status lines written at the bottom of the Camera & Script control panel use the regular proportional font or an equally-spaced font. See the Use Monospaced Font command just above for more details on using a monospaced font.
Run at Program Start command (Script menu)
Use this command to choose a script to run when the program starts. The menu entry shows up as checked when a script has been chosen. When you select this command, a dialog will open with a drop-down list in which you can select the script by its name or number. It is best to have a (short) name assigned to the script so that if scripts are rearranged, or a different set is loaded, the program will not run the wrong script. This script may do complex operations.
Run at Program End command (Script menu)
Use this command to choose a script to run when the program exits, just as for previous command for a startup script. This script is run after the program asks whether to save the Navigator and log and leaves Low Dose mode, if appropriate, and saves settings. These steps will be skipped when the program re-enters its exit routine after the script is run. While the script may do complex operations, the user should be warned if they are going to take more than a few seconds.
Run if Program Idle command (Script menu)
Use this command to choose a script to run periodically when the program is not busy doing any other operations. When you select this command, a dialog will open with a drop-down list in which you can select the script by its name or number; having a named script is advisable. After specifying the script, you can then enter the interval in seconds at which the script should run. It will not run with an interval of 0, so setting it to 0 would be a quick way to disable it. The menu entry shows up as checked when a script has been chosen and the interval is nonzero.
Open Editors on Start command (Script menu)
Use this command to control whether editor windows are restored to their last state when the program is restarted. In addition, if this option is selected, editor windows will be opened or closed when a new settings file is read to match the state when those settings were saved.
Verbose command (Script menu)
Use this command to set the initial value of the verbose option when a script is started. With this option on, each script command will be echoed to the log before being executed. The option value can be changed by the Verbose command within a script.