As is traditional, we will start with a simple ‘Hello World’ example. This script installs a new command in the command menu which, when clicked, launches an ‘alert’ that says “Hello World”.
constant meta = "Script by YOUR NAME. http://YOUR_URL" // ON LOAD, INSTALL A MENU COMMAND TO LAUNCH YOUR SCRIPT on Load InstallMenuCommand("Hello", "Hello") end // THE SCRIPT CALLED 'HELLO' WILL LAUNCH WHEN THE MENU COMMAND // IS CLICKED on Hello let greeting = "Hello World" syslog(greeting) Alert(greeting) end
To install, you can follow these steps:
Option A: Copy / Paste
- copy the text of the script above;
- open the MWScript editor (Show > Scripts or Ctrl+Shift+S);
- click ”+” in the bottom left corner;
- choose Add a new script;
- name it “Hello_World”;
- paste in the text;
- click Activate (green button at the top of the screen) to activate the script.
Option B: Download and Install
- make sure MoneyWorks is open (preferrably in the sample document, Acme Widgets);
- download the script here;
- open the file;
- click Yes to install;
- click Close to close the installation dialogue;
- click Activate (green button at the top of the screen) to activate the script.
Running the Script
Once installed and activated, the script adds a new ‘Hello’ command to the command menu.
Click Command > Hello and you will see a ‘Hello World!’ alert.
Open the MWScript editor at Show > Scripts ( or Ctrl + Shift + S), click on ‘Log Files’ and you will see that ‘Hello World’ has also been printed to the log file.
In the next post, we’ll take a closer look at how this all works.