A first example

A first example

As a very simple example, let’s display the number of Mail accounts for the current user. Note the template string in the call to displayDialog in line 5: This form will be used quite often because it allows very compact, albeit sometimes a bit strange looking strings. Also, it is very easy to embed variable values or expressions in the string itself.

1
2
3
4
5
6
7
(() => {
    const app = Application("Mail");
    app.includeStandardAdditions = true;
    const accountNo = app.accounts().length;
    app.displayDialog(`You have ${accountNo} mail accounts`,
       {withTitle: "Mail info"});
})()

Displaying the number of mail accounts

About