Tips for Writing Scripts

A script window is simply a spreadsheet of ME'scope commands. Each script command is defined by selecting a Target Window and a Target Command to execute in that window.  Every ME'scope menu command can be added to a script.  When one of the commands in its Run menu is executed, all commands in a script window are executed in sequence from top to bottom.

If a command requires parameters, they can be entering into a second spreadsheet at the bottom/right of the script window.  If a command requires parameters and it has not been parameterized yet the Open Dialog button on its line in the script will be set to Yes, If a command has been parameterized, setting its Open Dialog button to No will allow you to enters it parameters in the second spreadsheet

Hotkeys

A Hotkey is created and edited with the Script | Hotkeys | Define Hotkeys command. Each Hotkey is displayed on the top menu bar or the command ribbon in ME'scope. When a Hotkey is pressed, the script referenced by the Hotkey will be executed.

When a new script window is created and saved, a Hotkeyis also created for that script and displayed on the ME’scope menu bar or ribbon.

Hotkeys in Console

When a Hotkey is also assigned to a Machine, Site or Test Article  in the Archival Database, that Hotkey is also displayed for that Machine, Site, or Article on the Hotkeys ribbon in Console. By pressing Hotkeys in Console, an operator can remotely execute scripts in ME'scope.

Scripts Executing Scripts

Each script window can execute other script windows. This allows you to break up a large script into a series of smaller scripts.

Global Variables

Scripts can also share variables, called Global Variables.  Global Variables are defined with the Script | Variables | Define Global Variables command.  Using Global Variables and the other commands in the Script | Variables menu is more advanced, but they are very handy when you need them.

Steps for Writing a Script

Writing a script is like designing and creating a structure model.  It takes a little practice to do it efficiently.  Below is a list of helpful habits to use to write a script,

  1. Decide how many separate functions you want to perform with ME'scope, one per script

  2. Execute File | New | Script and create a script window to perform each function 

  3. Hold down the Ctrl key and press a Hotkey to open its script window

  4. Start adding ME'scope commands to the script

A first helpful command to add to each script is PRJ ME'scope > Windows | Minimize All. When executed, this command clears the ME'scope Work Area. A second command to add to a script is PRJ ME'scope > Script | Window | Position. When executed, this command opens and positions an ME'scope window in the Work Area.  Usually, several of these commands are necessary to position the windows associated with the script.

Debugging a Script

  1. Add a command to the script

  2. Press its Hotkey to execute the script with the new command in it

  3. Hold down Ctrl and press the Hotkey again to edit the command or add another command