Starting Guide for Mnova scripts


The availability of scripting in Mnova provides opportunities and benefits both for skilled NMR and casual, non-expert users. Let's see how to get started with it.

Loading a script in Mnova.

Several sample scripts can be found on the 'Scripts' Menu.


You can also load new scripts by invoking the 'Scripts/Run Script...' menu. To make your own scripts appear on that menu read the 'Where should the scripts be saved' tutorial.

Creating your first script: Hello World

A "hello world" program has become the traditional first program that many books use to introduce a programming language. It will act as a cheatsheet for you until you familiarize yourself with the language. The point of this application is to use all the most commonly used elements of Mnova Script language and putting it in a single place so that you can refer to it later. We will start showing the basic elements of an Mnova script and from that point you can add more advanced methods. Mnova scripts can be created with any text editor, although Mnova includes a specialized script editor with syntax highlighting and debugging output capabilities. This text editor is available from the 'Scripts/Edit Script' menu command. Issue this command and type in the following text:

 //GIU menuname="HelloWorld" shortcut="Ctrl+1" tooltip="Hello World" icon="C:/hello.jpg"/> function HelloWorld() { MessageBox.information("Hello World"); }}

In this example we have defined a function called helloWorld() which will simply display a message box with the text ‘Hello World’. Note that MessageBox is in bold, meaning that Mnova script editor recognizes it as a valid function. Next, go to the edit control at the top of the script editor and type:


Do not forget the brackets as they are required by the scripting framework in order to properly interpret the function. Once you have typed it, click on the green arrow at the right side of the edit control. You should get the pop up message box. Please note that you will be able to load/save any script by using the applicable buttons load and save. The play button will be used to run a script by typing the function on the edit box, whilst the stop button will stop a script in action. Clicking on the 'Help' button or pressing 'F1' will show you the 'Scripting help' window.

Where to find out more

The Mnova manual which can be downloaded from here or accessed through the 'Help/Contents" menu in MestReNova has a chapter devoted to scripts. You can also contact us if you need our team to develop scripts for you or if you need customized in-house/web training.


About Author


Comments are closed.