Scripts allow you to automate operations within MoneyWorks. They can read external files (either from your local volumes, or from a web server), intercept user-interface actions, create and update records and more.

A number of sample scripts are included in the Acme Widgets sample file. These are turned off by default, but you can easily turn them on to see how scripts work, and to play with the scripting language.

You can access the scripts by:

  1. Choose Show>Scripts

The Scripts Management window will open.

The first time you do this the scripts window will be empty. In the example above, there are three scripts (listed down the side). The “test” and “external” scripts are activated (indicated by the green tick), whereas the “Pricebook” script is deactivated, so will not run (indicated by the red cross).

To view a particular script:

  1. Click on the script in the sidebar

The script contents will be displayed in the body of the window, where it can be edited. If you do edit a script, you will need to activate it again (see below).

To activate a script

  1. Select the script in the sidebar by clicking it (if it is not already selected)
  1. Click the Activate toolbar icon

A green tick will appear next to the script on the sidebar indicating that it has been activated. If there is a syntax error in the script (i.e. some invalid text that the script compiler doesn't recognise), the script will not activate, and a tooltip will alert you to the error and where it occurs (and the part the script at and following the error will be coloured orange).

To deactivate a script

  1. If the script is not the currently selected one, click on it in the sidebar
  1. Click the Deactivate toolbar icon

If the script has an Unload handler, it will be called.

After the script is unloaded, a red cross will appear next to the script's name in the sidebar indicating that it is no longer active.

Note: If the script contains a public handler, any other scripts that use that handler will also be deactivated.

"Running" scripts

Usually, scripts will implement Handlers that allow the script to respond to certain user actions (like opening a window for a record, clicking a custom toolbar icon, or tabbing out of a particular field). The Load handler can be considered the main entry point of a script in that Load is called when you activate the script or the script is auto-activated when you log in to the document.

If you want a script to just do one thing, the Load handler is the place to do that thing. Having activated the script and had the Load handler execute, keep in mind that the script stays loaded, and the Load handler will execute the next time you (or anyone else) logs into the document. If you don't want this, you should deactivate the script.