96
© 2009 MESTRELAB RESEARCH MestReNova Scripting Manual Last Revision: 30-Mar-2009

Scripting With Mnova 5.3.0

Embed Size (px)

Citation preview

Page 1: Scripting With Mnova 5.3.0

© 2009 MESTRELAB RESEARCH

MestReNova Scripting Manual

Last Revision: 30-Mar-2009

Page 2: Scripting With Mnova 5.3.0

MestreNova Scripting

by MESTRELAB RESEARCH

This is the scripting manual of MestreNova 5.3

Page 3: Scripting With Mnova 5.3.0

All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, ormechanical, including photocopying, recording, taping, or information storage and retrieval systems - without thewritten permission of the publisher.

Products that are referred to in this document may be either trademarks and/or registered trademarks of therespective owners. The publisher and the author make no claim to these trademarks.

While every precaution has been taken in the preparation of this document, the publisher and the author assume noresponsibility for errors or omissions, or for damages resulting from the use of information contained in this documentor from the use of programs and source code that may accompany it. In no event shall the publisher and the author beliable for any loss of profit or any other commercial damage caused or alleged to have been caused directly orindirectly by this document.

Mnova Scripting

© 2009 MESTRELAB RESEARCH

Page 4: Scripting With Mnova 5.3.0

Mnova Scripting4

© 2009 MESTRELAB RESEARCH

Table of Contents

Foreword 0

Part I Scripts 6

................................................................................................................................... 131 Connecting scripts with Mnova objects

................................................................................................................................... 222 Connecting scripts with Mnova GUI

................................................................................................................................... 223 Mnova script reference

................................................................................................................................... 614 Mnova Properties

................................................................................................................................... 655 GUI Actions

................................................................................................................................... 706 Running Scripts from the command line

................................................................................................................................... 717 Scripts Samples

Index 0

Page 5: Scripting With Mnova 5.3.0

Part

I

Page 6: Scripting With Mnova 5.3.0

Mnova Scripting6

© 2009 MESTRELAB RESEARCH

1 Scripts

Scripting with Mnova

Benefits and uses

The availability of scripting in Mnova provides opportunities and benefits both for skilled NMR andcasual, non-expect users:

· Users are less dependent on the application developers for new features since scripting allowsthem to implement minor features themselves which can be deployed to less expect users.

· NMR administrators can write scripts to customize applications before deploying them to agroup of users. For example, an NMR manager could create a script to automate someparticular processing which he can distribute among his users in such a way that they willsimply have to click one button (e.g. toolbar button) to apply that processing.

· Mnova developers can use scripting to prototype new features that can later be incorporatedinto the next version of the application. This is ideal when a client requires someprocessing/analysis feature not available in the application and cannot wait until a new versionof Mnova is released.

· Mnova scripting language is based on an ECMAScript-based language making it easier forexisting Web developers to customize and extend Mnova.

In essence, nearly everything that can be done with the Mnova graphical interface (UI) can bereproduced with Mnova's scripting module, making it very easy to automate repetitive tasks. Forexample, you may have to routinely process 1H NMR spectra using the same processing operations.You can create a script which wraps up all these processing functions in such a way that by simplyclicking a toolbar button or pressing a keyboard shortcut, all of your 1H NMR spectra will be processedaccordingly.Furthermore, if some particular processing function is not available in Mnova, you can create a scriptwhich modifies the spectral data points according to your requirements.

Introducing Mnova Script – Hello World

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

Page 7: Scripting With Mnova 5.3.0

7

© 2009 MESTRELAB RESEARCH

In this example we have defined a function called helloWorld() which will simply display a messagebox with the text ‘Hello World’. Note that MessageBox is in bold, meaning that Mnova script editorrecognizes it as a valid function. Next, go to the edit control at the top of the script editor and type helloWorld(). Do not forget thebrackets 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 thepop up message box.

Page 8: Scripting With Mnova 5.3.0

Mnova Scripting8

© 2009 MESTRELAB RESEARCH

It is also possible to write information directly on the output control in the script dialog by using theprint command as showed below. This is very useful when debugging scripts.

Page 9: Scripting With Mnova 5.3.0

9

© 2009 MESTRELAB RESEARCH

As Mnova scripting is an ECMAScript-based language, you can use any of the many functions andstatements supported by this standard such as loops, conditions, etc. Remember that JavaScript isECMAScript based too so if you are familiar with it or with C/C++, writing Mnova scripts should be veryeasy for you. If you are not familiar with the ECMAScript language (http://doc.trolltech.com/4.3/ecmascript.html), there are several existing tutorials and books that coverthis subject, such as JavaScript: The Definitive Guide.

Page 10: Scripting With Mnova 5.3.0

Mnova Scripting10

© 2009 MESTRELAB RESEARCH

Where should the scripts be saved?

In principle you could save your scripts anywhere in your computer. However, it’s stronglyrecommended to save them in the scripts folder which you will find in your application data folder. InWindows XP this is usually located in:

C:\Documents and Settings\user\program data\Mestrelab ResearchS.L\MestReNova\scripts

This is very important to allow Mnova to find these scripts when starting in such a way that they can beadded to the GUI of Mnova (e.g. Toolbars, Menus, etc).

For example, type the following script:

// <GUI menuname="Hello" shortcut="Ctrl+1" tooltip="Hello World" />function HelloWorld(){

MessageBox.information("Hello World");}

And save it in the scripts directory (program data …) . Now close Mnova and open it again.

Page 11: Scripting With Mnova 5.3.0

11

© 2009 MESTRELAB RESEARCH

You will appreciate that the script is available in the menu bar. The key to get this working lies in thefirst line of the script (and of course, in the fact that Mnova can locate the script as it has been saved inthe appropriate folder):

// <GUI menuname="Hello" shortcut="Ctrl+1" tooltip="Hello World" />

This line is used to instruct Mnova about the name to be displayed in the scripts menu along with thekeyboard shortcut and the text used as a tooltip. For a full description on the usage of this line, seeconnecting scripts and Mnova GUI section below.

In any case, you can add any desired (or remove any undesired) folder as a 'Script Directory' byfollowing the menu 'Scripts/Scripts Directories':

It is also possible to create dialog boxes with controls. The script below shows a simple example.

Page 12: Scripting With Mnova 5.3.0

Mnova Scripting12

© 2009 MESTRELAB RESEARCH

Execution of this script results in the following dialog box:

Page 13: Scripting With Mnova 5.3.0

13

© 2009 MESTRELAB RESEARCH

1.1 Connecting scripts with Mnova objects

Simple access to an NMR spectrum

The examples we have shown so far are certainly not very useful. The good thing about scripting inMnova is that it can be used to manipulate objects (e.g. spectra, molecules, pictures, etc) in Mnovaand automated repetitive tasks. This section will explain how to access an NMR spectra from withinthe scripting framework.

Consider the following code snippet:

function dumpSpectrum(){

//To get the active spectrumvar spectrum = nmr.activeSpectrum();//The function isValid informs about if the spectrum obtained is

correctprint( spectrum.isValid() );//To print the spectrum informationprint( "Frequency: " + spectrum.frequency() );print( "Lowest Frequency: "+spectrum.hz() );print( "Real: "+spectrum.isReal );print( "Solvent: "+ spectrum.solvent );

//To get information about each dimensionvar dCount = spectrum.dimCount;for( var i = 1; i <= dCount; i++ ){

print( "Dimension "+i );print( "Nucleus: "+spectrum.nucleus(i) );//Spectral Sizeprint( "Spectral Size: "+spectrum.count(i) );

}//To print the value of one of the spectral pointsif( spectrum.isReal )

print(spectrum.real(100));else

print( spectrum.real(100)+" + "+spectrum.imag(100)+"j" );}

The first thing to note is the nmr object. This object gives access to the NMR plug-in framework andas such it allows you to get access to the NMR spectra in Mnova. For example,nmr.activeSpectrum()function makes it possible to select current active spectrum in Mnova.

Page 14: Scripting With Mnova 5.3.0

Mnova Scripting14

© 2009 MESTRELAB RESEARCH

From that point, you can read relevant information of the NMR spectrum such as the number of points,spectral width, etc. For more information about the spectrum properties see the reference.

Let’s now move to a more comprehensive example which will illustrate, step by step, how to access allobjects within an Mnova page.

Having access to multiple objects: the layout script

As an illustrative example, we will build a script which will make it possible to organize different objectscontained within a page. This script will be called layout for obvious reasons.To start off with, open a spectrum, a molecule and a picture (which could be, for example, yourcompany logo). The following picture shows the initial conditions for this example:

The goal here will be to create a script which will arrange these 3 objects in such a way that the picturewill be located at the left side of the page whilst the spectrum and the molecule will be moved next tothe picture.

// <GUI menuname="Layout"shortcut="Ctrl+2" tooltip="Layout" />function layout(){

var w = newDocumentWindow(Application.mainWindow.activeWindow());

var p = new Page(w.curPage());var n = p.itemCount();

for(i=0; i<n; i++)

Page 15: Scripting With Mnova 5.3.0

15

© 2009 MESTRELAB RESEARCH

{var item = p.item(i);var width = item.width();var height = item.height();switch(item.name()){

case "NMR Spectrum":item.left = p.left + 50;item.right = p.right - 10;item.top = p.top+20;item.bottom = p.bottom;

break; case "Molecule":

item.left = p.left + 50;item.right = item.left + width;item.top = p.top;item.bottom = p.top + height;

break;case "Image":

item.left = p.left;item.right = item.left + width;item.top = p.top;item.bottom = item.top + height;

break;

}}w.update();

}

Every object in Mnova is contained in a page which in turn is contained in a document. So the firstthing we should get access to is the document. This is done in this line:

var w = new DocumentWindow(Application.mainWindow.activeWindow());

Basically we access to the document window (DocumentWindow) via the Application object. Once we have the document, we can easily access to the currently active page through Page objectlike this:

var p = new Page(w.curPage());

Now we are ready to navigate through all the objects contained in this page. For every object, theexact type is checked within the switch command and then the objects are repositioned accordingly.This is the result for this example.

Page 16: Scripting With Mnova 5.3.0

Mnova Scripting16

© 2009 MESTRELAB RESEARCH

Tuning up the layout script

We will now modify the layout script in order to achieve the following two objectives:1. Load the image from a file2. Show the spectrum title automatically on the page when the script is executed

First off, we will show how to load an image from the disk. To do that, you have to use the serializationobject. For example, assuming that the image is located in c:\kk\logo.jpeg, you can use this code:

serialization.open("c:\\kk\\logo.jpeg");

(Note the double back slash!).

Next thing is how to show the spectrum title on the page. In order to do that, it will be necessary tocreate a specialized NMR spectrum object rather than using the default properties available in everyitem object. See the following code snippet:

case "NMR Spectrum":var nmrSpc = new NMRSpectrum(item);nmrSpc.left = p.left + 50;nmrSpc.right = p.right - 10;nmrSpc.top = p.top+20;nmrSpc.bottom = p.bottom;var tit = draw.text("<h3>"+nmrSpc.title+"</h3>", true);tit.left = p.left+50;tit.top = p.top;

break;

Page 17: Scripting With Mnova 5.3.0

17

© 2009 MESTRELAB RESEARCH

The first thing to note is the NMRSpectrum object. It will allow us to construct a specialized NMRspectrum object if a valid item is provided. From that point on, we will be able to change any spectrumproperties or gain access to any of its elements such as the spectrum title. In this particular examplewe read the title using nmrSpec.title property which is then plotted with the draw.text command andmoved to the top of the page next to the logo image. It’s important to note that in linetit = draw.text("<h3>"+nmrSpc.title+"</h3>", true);

we are creating a new object (or item). This means that the array of items will not be the same nowand the internal for loop will not longer be valid. One could think of just incrementing the number ofitems by one unit, but it’s not guaranteed that the internal order of the objects is the same afterinserting a new one. The simplest solution is to make a temporary copy of the original objects in thepage (before creating the title object) as this:

var c = p.itemCount();var i = 0;var itemArray = new Array(c);

And then we can iterate through all these items:

for( i = 0; i<itemArray.length; i++ ){

var item = itemArray[i];// ...

}

The complete new script looks like this:

// <GUI menuname="Layout2" shortcut="Ctrl+2" tooltip="Layout2" />function layout2(){

var w = new DocumentWindow(Application.mainWindow.activeWindow());var p = new Page(w.curPage());serialization.open("c:\\kk\\logo.jpeg");var c = p.itemCount();var i = 0;var itemArray = new Array(c);for(i=0; i<c; i++){

itemArray[i] = p.item(i);}for( i = 0; i<itemArray.length; i++ ){

var item = itemArray[i];var width = item.width();var height = item.height();

switch(item.name()){

case "NMR Spectrum":var nmrSpc = new NMRSpectrum(item);nmrSpc.left = p.left + 80;nmrSpc.right = p.right - 10;nmrSpc.top = p.top+20;nmrSpc.bottom = p.bottom;var tit = draw.text("<h3>"+nmrSpc.title+"</h3>",

true);

Page 18: Scripting With Mnova 5.3.0

Mnova Scripting18

© 2009 MESTRELAB RESEARCH

tit.left = p.left+50;tit.top = p.top;print(item.name());

break; case "Molecule":

item.left = p.left + 90;item.right = item.left + width;item.top = p.top+50;item.bottom = item.top + height;print(item.name());

break;case "Image":

item.left = p.left;item.right = item.left + width;item.top = p.top;item.bottom = item.top + height;print(item.name());

break;}

}w.update();

}

Once you have the script saved (please bear in mind that the script file will need to have the samename as the function which you want to call, in this case the name of the script must be ‘layout2.qs’) inthe Mnova scripts folder (and then have restarted the program), you will be able to add it to the toolbarjust by following the menu: 'View/Toolbars/Customize Toolbars'. This will display the 'CustomizeToolbars' dialog box. Then, click on the ‘+’ button to create a new toolbar and type its name (ScriptsToolbar) by clicking on the ‘Rename’ button.

Page 19: Scripting With Mnova 5.3.0

19

© 2009 MESTRELAB RESEARCH

Next, navigate to the 'Script' icon (Layout2) in the 'Actions' menu (at the left-hand side of the window)and Click on the 'Right Arrow' button to add the 'Layout2’ script to the 'New Toolbar'.

Page 20: Scripting With Mnova 5.3.0

Mnova Scripting20

© 2009 MESTRELAB RESEARCH

Finally, click on OK and you will be able to see the 'Layout2' icon in the 'New toolbar'. You will also beable to introduce the script in any existing contextual menu by following a similar procedure in the ‘Customize Context menus’ dialog box.

Custom NMR Processing

There are two ways to process NMR spectra via scripting:1. By means of Processing Templates2. By using the Processing interface

1 Processing templates

It is possible within Mnova to process a 1D or 2D NMR spectrum via scripting by using the processingtemplates (generated with the Full Processing feature). As you can see in the below example, you canprocess (with an easy script) any kind of spectrum (1H, 13C, 1D or 2D). You only need to create theprocessing template for each experiment. In the example below we have created 3 differentprocessing templates, one for the processing of 1H-NMR spectra (1H.mnp), the second for theprocessing of 13C-NMR spectra (13C.mnp) and the last one for the processing of COSY spectra(COSY.mnp). As you can see in the scripts, the three the templates were saved at c:/kk/ (of course

Page 21: Scripting With Mnova 5.3.0

21

© 2009 MESTRELAB RESEARCH

you can change this path and also the name of the template files).

function procTemplate(){

var spec = new NMRSpectrum( nmr.activeSpectrum() );var processing = new String;if (!spec.isValid())

return;if (spec.dimCount == 1){

if (spec.nucleus() == "1H")processing = "c:/kk/1H.mnp";

else if (spec.nucleus() == "13C")processing = "c:/kk/13C.mnp";

}else if (spec.dimCount == 2){

if (spec.nucleus(1) == "1H" && spec.nucleus(2) == "1H")processing = "c:/kk/COSY.mnp";

}nmr.processSpectrum(spec, processing);

}

2 Processing interface

The Processing interface makes it possible to change or apply any processing operation available inMnova. For example, let’s make a simple script which will set an exponential weighting function:

function myProcess(){

var spec = new NMRSpectrum( nmr.activeSpectrum() );var p = new NMRProcessing(spec.proc);

p.setParameter("Apodization[1].Apply", true);p.setParameter("Apodization[1].Exp.Apply", true);

p.setParameter("Apodization[2].Exp.Value", 0.5);print(p.getParameter("Apodization[1].Exp"));

spec.proc = p;spec.process();mainWindow.activeWindow().update();

}

After creating a spectrum object which represents current active spectrum, we create a processingvariable (p) which represents the processing operations for that particular spectrum. Once this newobject is created, we can read or change its values using getParameter and setParameter functions.For instance, in this example we first set to true the Apodization property (otherwise no apodization willbe applied) and then, after setting to true the exponential function, we set the line broadening to 0.5Hz.Finally, when we are done, we assign this processing object to the spectrum object (spec.proc =p;) and we call spec.process(); to actually apply all the processing operations.

Page 22: Scripting With Mnova 5.3.0

Mnova Scripting22

© 2009 MESTRELAB RESEARCH

1.2 Connecting scripts with Mnova GUI

As you have seen in the examples above, it is possible to insert any script in the Mnova Scripts menu,contextual menus or toolbars.

The key to get this working lies in the first line of the script (and of course, in the fact that Mnova canlocate the script as it has been saved in the appropriate folder):

// <GUI menuname= "MyProcess" shortcut="Ctrl+1" tooltip="Exponential0.5" icon="C:/bin2.jpg" />

This line is used to instruct Mnova about the name to be displayed in the scripts menu along with thekeyboard shortcut and the text used as a tooltip. Please bear in mind that the user is also able to useany created image file as icon. In this case, the name of the script is MyProcess, the shortcut is Ctrl+1,the tooltip is Exponential 0.5 and the icon used was saved at C:/bin2.jpg.

You will be able to see in the picture below, that we have added the script ‘MyProcess’ to the ‘Scripts’menu with the corresponding shortcut (Ctrl+1) and that we have introduce our own icon on the toolbar(red square in the picture below).

Please bear in mind that the script file will need to have the same name that the function which youwant to call, in this case the name of the script must be ‘MyProcess.qs’, because the name of thefunction is: myProcess().

1.3 Mnova script reference

This reference contains a list of objects, functions and properties supported by Mnova script. For acomplete ECMAScript Reference, consult this link: http://doc.trolltech.com/4.3/ecmascript.html

Example scripts are present in the examples/scripts installation directory and some of them aredescribed here.

· Application

Application object

o property mainWindow: MainWindowMain window object

o property name: StringApplication name

Page 23: Scripting With Mnova 5.3.0

23

© 2009 MESTRELAB RESEARCH

o property version: StringApplication version

o property version.build: NumberVersion build number

o property version.full: StringFull version string

o property version.major: NumberVersion major number

o property version.minor: NumberVersion minor number

o property version.revision: NumberVersion revision number. It is recommended to use this number to compare software versions.

· Arrow

Arrow page item. Inherits PageItem

o property endX: Number

o property endY: Number

o property startX: Number

o property startY: Number

o constructor Arrow(Arrow aArrow)

§ Arrow aArrow

o function toString(): String

· Atom: You will find below a list of the objects related to the atom of the molecular structures

o property charge: Number

o property elementSymbol: String

o property isotope: Number

o property label: String

o property nH: Number

o property nHAll: Number

o property text: String

o property valence: Number

o constructor Atom(Atom aAtom)

Page 24: Scripting With Mnova 5.3.0

Mnova Scripting24

© 2009 MESTRELAB RESEARCH

§ Atom aAtom

o function toString(): StringString representation of the object

· BinaryStream: The BinaryStream object provides serialization of binary data to a file. Examplescripts are present in the examples/scripts installation directoryo property pos: Number

Gets/sets the file position corresponding to the current position of the stream. Returns -1 if an erroroccurso property endianness: Number

Gets/sets the serialization endiannessValid Values: {BinaryStream.eBig, BinaryStream.eLittle}

o Constructor BinaryStream(File aFile)§ File aFile

Description:Constructs a BinaryStream that operates on aFile

o Constructor BinaryStream(BinaryStream aStream)§ BinaryStream aStream

Constructs a BinaryStream that is a copy of aStream

o function atEnd(): Boolean

Returns true if there is no more data to be read from the BinaryStream

o Constructor skip(Number aSize)§ Number aSize

Description:Skips the aSize bytes in the stream

o function writeInt8(Number aValue)§ Number aValue

Description:Writes a signed byte to the stream

o function writeInt16(Number aValue)§ Number aValue

Description:Writes a signed 16-bit integer to the stream

o function writeInt32(Number aValue)§ Number aValue

Description:Writes a signed 32-bit integer to the stream

o function writeInt64(Number aValue)§ Number aValue

Description:Writes a signed 64-bit integer to the stream

o function writeInt8(Number aValue)§ Number aValue

Description:Writes a signed byte to the stream

o function writeBool(Boolean aValue)§ Boolean aValue

Description:Writes a boolean to the stream

o function writeReaI32(Number aValue)

Page 25: Scripting With Mnova 5.3.0

25

© 2009 MESTRELAB RESEARCH

§ Number aValueDescription:Writes a 32-bit real (float) to the stream

o function writeReaI64(Number aValue)§ Number aValue

Description:Writes a 64-bit real (float) to the stream

o function writeString(String aValue)§ String aValue

Description:Writes a String to the stream

o function writeCString(String aValue)§ String aValue

Description:Writes the '\0'-terminated (C-like) string to the stream

o function writeBytes(String aValue, Number aSize)§ String aValue§ Number aSize

Description:Writes aSize bytes from aValue to the stream

o function readInt8()Description:Reads a signed byte from the stream

o function readInt16()Description:Reads a signed 16-bit integer from the stream

o function readInt32()Description:Reads a signed 32-bit integer from the stream

o function readInt64()Description:Reads a signed 64-bit integer from the stream

o function readBool()Description:Reads a boolean from the stream

o function readReal32()Description:Reads a 32-bit real (float) from the stream

o function readReal64()Description:Reads a 64-bit real (float) from the stream

o function readString()Description:Reads a String from the stream

o function readCString()Description:Reads the '\0'-terminated (C-like) string from the stream

o function readBytes(Number aSize)§ Number aSize

Description:Reads aSize bytes from the stream

o function toString(): String

· Bond:

Page 26: Scripting With Mnova 5.3.0

Mnova Scripting26

© 2009 MESTRELAB RESEARCH

o enumeration BondStereo: Number = {bsCisOrTrans, bsDown, bsEither, bsNone, bsUp}

o enumeration BondType: Number = {btAny, btAromatic, btDouble, btDoubleOrAromatic, btSingle,btSingleOrAromatic, btSingleOrDouble, btTriple}

o property atom1: Number

o property atom2: Number

o property bondStereo: BondStereo

o property bondType: BondType

o constructor Bond(Bond aBond)

§ Bond aBond

o function toString(): StringString reperesentation of the object

· Dir: The Dir object provides access to directory structures and their contents. All the scripts arepresent in the examples/scripts installation directory. Example scripts are present in the examples/scripts installation directory

· The Dir object provides access to directory structures and their contents

o property absPath: StringReturns the absolute path

o property exists: BooleanReturns true if the directory exists

o property name: StringReturns the name of the directory

o constructor Dir(String aDirPath)Constructs a Dir pointing to the given directory path

§ String aDirPath

o constructor Dir(Dir aDir)Constructs a copy of the aDir

§ Dir aDir

o function Dir.application(): StringReturns the absolute path of the application executable

o function cd(String aDirName): BooleanChanges the Dir's directory to dirName

§ String aDirName

o function cdUp(): Boolean

Page 27: Scripting With Mnova 5.3.0

27

© 2009 MESTRELAB RESEARCH

Changes directory by moving one directory up from the Dir's current directory

o function Dir.cleanDirPath(String aDirPath): StringRemoves all multiple directory separators "/" and resolves any "."s or ".."s found in the path,aDirPath

§ String aDirPath

o function Dir.convertSeparators(String aDirPath): StringReturns aDirPath with the '/' separators converted to separators that are appropriate for theunderlying operating system

§ String aDirPath

o function Dir.current(): StringReturns the absolute path of the application's current directory

o function Dir.drives(): ArrayReturns a list of the root directories on this system

o function entryList(String aWildcard, Number aKind, Number aSortFlags): StringReturns a list of the names of all the files and directories in the directory, ordered according to thename and attribute filters

§ String aWildcard - Filter that understands * and ? wildcards

§ Number aKind - Filter option. Combination of the following flagsValid values: {Dir.AccessMask, Dir.All, Dir.Dirs, Dir.Drives, Dir.Executable, Dir.Files, Dir.Hidden,Dir.Modified, Dir.NoSymLinks, Dir.Readable, Dir.RWEMask, Dir.System, Dir.TypeMask,Dir.Writable}

§ Number aSortFlags - Sort option. Combination of the following flagsValid values: {Dir.DirsFirst, Dir.IgnoreCase, Dir.Name, Dir.Reversed, Dir.Size, Dir.SortByMask,Dir.Type, Dir.Unsorted}

o function fileExists(String aFileName): BooleanReturns true if the file called aFileName exists

§ String aFileName

o function filePath(String aFileName): StringReturns the path name of a file in the directory. Does not check if the file actually exists in thedirectory

§ String aFileName

o function Dir.home(): StringReturns the absolute path of the user's home directory

o function mkdir(String aDirName): BooleanCreates a sub-directory specified by aDirName

§ String aDirName

o function mkpath(String aDirPath): BooleanCreates the directory path aDirPath. The function will create all parent directories necessary to

Page 28: Scripting With Mnova 5.3.0

Mnova Scripting28

© 2009 MESTRELAB RESEARCH

create the directory

§ String aDirPath

o function rmdir(String aDirName): BooleanRemoves the directory specified by aDirName

§ String aDirName

o function rmpath(String aDirPath): BooleanRemoves the directory path aDirPath. The function will remove all parent directories in aDirPath,provided that they are empty

§ String aDirPath

o function Dir.root(): StringReturns the absolute path of the root directory

o function Dir.setCurrent(String aDirPath): BooleanSets the application's current working directory to aDirPath

§ String aDirPath

o function Dir.temp(): StringReturns the absolute path of the system's temporary directory

o function toString(): String

· DocumentWindow: Represents a document object. The DocumentWindow object is amember of the DocumentWindows collection. The DocumentWindows collection contains all theopen document windows.

o constructor DocumentWindow(DocumentWindow aDocWin)

§ DocumentWindow aDocWin

o function close()Closes the document window

o function curPage(): PageReturns current page

See also: setCurPage, setCurPageIndex

o function page(Number aIndex): PageReturns the page number aIndex

§ Number aIndex

o function pageCount(): NumberNumber of pages of the document

o function selection(): ArrayReturns array of currently selected page items

Page 29: Scripting With Mnova 5.3.0

29

© 2009 MESTRELAB RESEARCH

o function setActive(PageItem aItem)Marks the aItem as active

§ PageItem aItem

o function setCurPage(Page aPage)Sets current page to aPage

§ Page aPage

See also: curPage, setCurPageIndex

o function setCurPageIndex(Number aPageIndex)Sets current page index to aPageIndex

§ Number aPageIndex

See also: curPage, setCurPage

o function setSelection(Array aItems)Marks the aItems as selected

§ Array aItems

o function toString(): String

o function update()Refresh the current page

· DrawPlugin: It is the object to add text objects to the document

o DrawPlugin ( DrawPlugin aDrawPlugin)

§ DrawPlugin aDrawPlugin

o function arrow(Number aStartX, Number aStartY, Number aEndX, Number aEndY, BooleanaShowStartHead, Boolean aShowEndHead): ArrowAdds an arrow to the document

§ Number aStartX - X coordinate of the starting point

§ Number aStartY - Y coordinate of the starting point

§ Number aEndX - X coordinate of the ending point

§ Number aEndY - Y coordinate of the ending point

§ Boolean aShowStartHead - Show start head

§ Boolean aShowEndHead - Show end head

o function ellipse(Number aWidth, Number aHeight): EllipseAdds an ellipse to the document

§ Number aWidth - Width

§ Number aHeight - Height

Page 30: Scripting With Mnova 5.3.0

Mnova Scripting30

© 2009 MESTRELAB RESEARCH

o function rectangle(Number aWidth, Number aHeight): RectangleAdds a rectangle to the document

§ Number aWidth - Width

§ Number aHeight - Height

o function text(String aText, Boolean aIsHtml): TextAdds a text box to the document

§ String aText - Text

§ Boolean aIsHtml - HTML text

o function toString(): String

· Ellipse Ellipse page item. Inherits PageItem

o constructor Ellipse(Ellipse aEllipse)

§ Ellipse aEllipse

o function toString(): String

· File :Example scripts are present in the examples/scripts installation directory

o property absDirPath: StringReturns the absulute path of the file's parent directory

o property name: StringReturns the file name

o property exists: BooleanReturns true if the directory existso property size: Number

Returns the file size

o Constructor File(String aFileName)§ String aFileName

Description:Constructs a new file object to represent the file with the given aFileName

o Constructor File(File aFile)§ File aFile

Description:Constructs a copy of the aFile

o function open(Number aMode): bool

§ Number aMode: This enum is used to describe the mode in which a file is openedValid Values: {File.ReadOnly, File.WriteOnly, File.ReadWrite, File.NotOpen}

Opens the file using aMode mode, returning true if successful

o function close(): Boolean

Closes the file and sets its open mode to File. NotOpen

o function remove(): Boolean

Removes the file. Returns true if successful. The file has to be closed before it is removed

o function File.remove(String aFileName): Boolean

Page 31: Scripting With Mnova 5.3.0

31

© 2009 MESTRELAB RESEARCH

§ String aFileName: Removes the file specified by the given aFileName. Returns true ifsuccessful

o function File.create(String aFileName): Boolean§ String aFileName: Creates the file specified by the given aFileName. Returns true if successful

o function File.exists(String aFileName): Boolean§ String aFileName: Returns true if the aFileName exists

o function File.rename(String aOldFileName, String aNewFileName): Boolean§ String aOldFileName§ String aNewFileName

Renames the file aOldFileName to aNewFileName. Returns true if successful

o function File.copy(String aFileName, String aNewFileName): Boolean§ String aFileName§ String aNewFileName

Copies the file aFileName to aNewFileName. Returns true if successful

o function toString(): String

· FileDialog:

The FileDialog object provides methods that allow users to select files or directories

o function FileDialog.getExistingDirectory(String aStartDirectory, String aDialogTitle): StringThe function creates a directory open dialog and returns an existing directory name selected bythe user

§ String aStartDirectory

§ String aDialogTitle

o function FileDialog.getOpenFileName(String aFileFilter, String aDialogTitle, String

aWorkingDirectory): StringThe function creates a file open dialog and returns an existing file name selected by the user

§ String aFileFilter

§ String aDialogTitle

§ String aWorkingDirectory

o function FileDialog.getOpenFileNames(String aFileFilter, String aDialogTitle, String

aWorkingDirectory): ArrayThe function creates a multiple file open dialog and returns one or more existing file namesselected by the user

§ String aFileFilter

§ String aDialogTitle

§ String aWorkingDirectory

o function FileDialog.getSaveFileName(String aFileFilter, String aDialogTitle, String

Page 32: Scripting With Mnova 5.3.0

Mnova Scripting32

© 2009 MESTRELAB RESEARCH

aWorkingDirectory): StringThe function creates a file save dialog and returns a file name selected by the user

§ String aFileFilter

§ String aDialogTitle

§ String aWorkingDirectory

· Integral: The Integral objects allow us to get information about the integration analysis. Theobjects of type Integrals have the following properties:

o Number IntegralValueDescription: returns the value of the integral

o Number rangeMinDescription: the minimum value of the integral range

o Number rangeMaxDescription: the maximum value of the integral range

o function Integral( Integral aIntegral):

§ Integral aIntegral:

Description: to create an integral

o function Integral( SpectrumRegion aSpectrumRegion, NMRSpectrum aSpectrum):

§ SpectrumRegion aSpectrumRegion:

§ NMRSpectrum aSpectrum

Description: to report the result of an automatic integral analysis from a region of a spectrum

o function toString( ): return

· Integrals: The Integral objects allow us to get information about the integration analysis. Theobjects of type Integrals have the following properties:

o property count: NumberNumber of integrals

o property normValue: NumberIntegrals normalization factor

o Integrals ( )Description: Constructs an empty integral list

o Integrals ( Integrals aIntegralList)

§ Integrals aIntegralList:

Description: constructs the integral list

o function at( Number aIndex): return Integral

Page 33: Scripting With Mnova 5.3.0

33

© 2009 MESTRELAB RESEARCH

§ Number aIndex:

Description: Returns the integral at the position aIndex

o function clear( ): return

Description: to clear the integrals

o function removeAt( Number aIndex): return

§ Number aIndex:

Description: to remove the integral at a determined chemical shift o function append( Integral aIntegral): return

§ Integral aIntegral:

Description: to add the integral to the list

o function toString( ): return

· JList. The JList objects allow us to get the information about the coupling constants values in themultiplet report. The objects of type JList have the following properties:

o Number countDescription: number of coupling constants values

o Number lengthDescription: number of coupling constants values

o JList ( JList aJList)

§ JList aJList:

o function at( ): return Number

Description: it returns the chemical shift value

o function sort( Boolean bAscending): return

§ Boolean bAscending:

Description: it sorts the elements in ascending/descending ordero function clear( ): return

Description: deletes all the coupling constants

o function removeAt( Number aIndex): return

§ Number aIndex:

Description: it removes the elemento function append( Number aJ): return

§ Number Number aJ:

Description: to add the J to the list

o function toString( ): return String

Page 34: Scripting With Mnova 5.3.0

Mnova Scripting34

© 2009 MESTRELAB RESEARCH

· MainWindow: Here it is a list of the objects related to the Mnova spectral window:

o MainWindow ( MainWindow aMainWnd)

§ MainWindow aMainWnd

o function newWindow( ): This function creates a new document window. Because no otherstatements in the document require the reference to the new window just opened, the statementdoes not assign its returned value to any variable. This is an acceptable practice in JavaScript ifyou don’t need the returned value of a function or method.

o function activeWindow( ): Returns a DocumentWindow object that represents the activedocument window

o function doAction(String aActName)Performs a GUI action

· String aActName - See list of actions

o function toString( ): This function returns string values (it ‘prints’ the information on the screen).Every JavaScript core language object and every DOM document object has a toString() methodassociated with it. This method is designed to render the contents of the object in as meaningful away as possible.

o function newDocument( ): returns a new document.

· MessageBox:

The MessageBox object provides a modal dialog with a short message, an icon, and buttons laid outdepending on the arguments

o enumeration Buttons: Number = {Abort, Apply, Cancel, Close, Discard, Help, Ignore, No,NoButton, NoToAll, Ok, Open, Reset, RestoreDefaults, Retry, Save, SaveAll, Yes, YesToAll}

o function MessageBox.critical(String aText, Buttons aButton1, Buttons aButton2, Buttons

aButton3, String aTitle): ButtonsOpens a critical message box with the title aTitle, the text aText and the buttons specified. Returnsthe identity of the button that was activated

§ String aText

§ Buttons aButton1

§ Buttons aButton2

§ Buttons aButton3

§ String aTitle

o function MessageBox.information(String aText, Buttons aButton1, Buttons aButton2, Buttons

aButton3, String aTitle): ButtonsOpens an information message box with the title aTitle, the text aText and the buttons specified.Returns the identity of the button that was activated

Page 35: Scripting With Mnova 5.3.0

35

© 2009 MESTRELAB RESEARCH

§ String aText

§ Buttons aButton1

§ Buttons aButton2

§ Buttons aButton3

§ String aTitle

o function MessageBox.question(String aText, Buttons aButton1, Buttons aButton2, Buttons

aButton3, String aTitle): ButtonsOpens a question message box with the title aTitle, the text aText and the buttons specified.Returns the identity of the button that was activated

§ String aText

§ Buttons aButton1

§ Buttons aButton2

§ Buttons aButton3

§ String aTitle

o function MessageBox.warning(String aText, Buttons aButton1, Buttons aButton2, Buttons

aButton3, String aTitle): ButtonsOpens a warning message box with the title aTitle, the text aText and the buttons specified.Returns the identity of the button that was activated

§ String aText

§ Buttons aButton1

§ Buttons aButton2

§ Buttons aButton3

§ String aTitle

· Molecule:

Molecule page itemInherits PageItem

o property atomCount: Number

o property bondCount: Number

o constructor Molecule(Molecule aMolecule)

§ Molecule aMolecule

Page 36: Scripting With Mnova 5.3.0

Mnova Scripting36

© 2009 MESTRELAB RESEARCH

o function atom(Number aIndex): AtomReturns the Atom object at aIndex

§ Number aIndex

o function atoms(): ArrayReturns array of Atom objects

o function bond(Number aIndex): BondReturns the Bond object at aIndex

§ Number aIndex

o function bonds(): ArrayReturns array of Bond objects

o function getMolfile(Boolean aOriginal = true): String

§ Boolean aOriginal - If true returns original molfile, otherwise the molfile is created

o function toString(): String

· Multiplet: The multiplet objects allow us to get the multiplet report. The objects of type Multiplethave the following properties:

o String categoryDescription: Category; multiplet (m), singlet (s), doublet (d) , triplet (t), etc.)

o Number deltaDescription: chemical shift

o String nameDescription: name of the multiplet

o Number rangeMinDescription: minimum value of the range of the multiplet

o Number rangeMaxDescription: maximum value of the range of the multiplet

o Number nHDescription: number of Hydrogens

o Multiplet (Multiplet aMultiplet)

§ Multiplet aMultiplet: to create a multiplet

o Multiplet (SpectrumRegion aSpectrumRegion, String aCategory)

§ SpectrumRegion aSpectrumRegion:

§ String aCategory:

Description: to create a multiplet indicating the region of the spectrum and the corresponding category(s, d, t, etc.)

o Multiplet (SpectrumRegion aSpectrumRegion, NMRSpectrum aSpectrum)

Page 37: Scripting With Mnova 5.3.0

37

© 2009 MESTRELAB RESEARCH

§ SpectrumRegion aSpectrumRegion:

§ NMRSpectrum aSpectrum:

Description: to report the result of an automatic multiplet analysis from a region of a spectrum

o function jList( Boolean aReduced): return

§ Boolean aReduced:

Description: returns the coupling constants

o function setjList( JList aJList): return

§ JList aJList:

Description: to assign a list of coupling constants to a multiplet

o function toString( ): return

· Multiplets: The multiplets objects allow us to get the multiplet report. The objects of typeMultiplets have the following properties:

o Number countDescription: Number of multiplets

o Multiplets ( Multiplets aMultipletList)

§ Multiplets aMultipletList:

o function at( Number aIndex): return Multiplet

§ Number aIndex

Description: Returns multiplet at the position aIndex

o function sort( Boolean bAscending): return

§ Boolean bAscending:

Description: Sort Ascending/Descendingo function clear( ): return

Description: delete all the multiplets

o function removeAt( Number aIndex): return

§ Number aIndex:

Description: delete the multiplet at aIndex chamical shifto append ( Multiplet aMultiplet): return

§ Multiplets aMultiplet:

Description: to add the multiplet to the list

o function toString( ): return String

· MultipletTable: It allows the user to get the multiplet table.

o MultipletTable ( MultipletTable aMultipletTable)

Page 38: Scripting With Mnova 5.3.0

Mnova Scripting38

© 2009 MESTRELAB RESEARCH

§ MultipletTable aMultipletTable

o function spectrum( ): return

Description: spectrum to which the table makes reference

function toString( ): return String

· NMRPlugin: The NMRPlugin objects allow us to process our NMR spectra. The objects of typeNMRPlugin have the following properties:

o NMRPlugin ( NMRPlugin aNMRPlugin)

§ NMRPlugin aNMRPlugin

o function activeSpectrum(): NMRSpectrumReturns the active spectrum

o function beginModification(NMRSpectrum aSpectrum)Save the current state of a spectrum

§ NMRSpectrum aSpectrum

o function endModification(NMRSpectrum aSpectrum)Used with beginModification creates a User Processing Command that allows Do/Undo

§ NMRSpectrum aSpectrum

o function multipletTable(): MultipletTableReturns the current Multiplet Table

o function peakTable(): PeakTableReturns the current Peak Table

o function process(String aProcFile)Reads a processing file and apply it to the active spectrum

§ String aProcFile - File Name

o function processSpectrum(NMRSpectrum aSpectrum, String aProcFile)Reads a processing file and apply it to a spectrum

§ NMRSpectrum aSpectrum

§ String aProcFile

o function toString(): String

· NMRProcessing: The NMRProcessing objects allow us to process the NMR spectra. Theobjects of type NMRProcessing have the following properties

o Boolean isValidDescription: The function isValid informs if the spectrum obtained is correct

Page 39: Scripting With Mnova 5.3.0

39

© 2009 MESTRELAB RESEARCH

o NMRProcessing ( )

o function toString( ): return

o function getParameter( String aArgumentString): return Variant

§ String aArgumentString: This string has the form function1.function2...functionN.parameter.

Description: Returns the value of the aArgumentString processing parameter. For example:“Apodization[1].Exp.Value” to return the value of the exponential apodization function. In order to seethe list of the aArgumentStrings, please click here

o function setParameter( String aArgumentString, Variant aValue): return Variant

§ String aArgumentString: This string has the form function1.function2...functionN.parameter

§ Variant aValue: Value

Description: Sets the value of the aArgumentString processing parameter.

This script can be used to obtain the desired parameters on your spectrum. You will be able to add orremove any parameter and to change the font by just using HTML code.

function spectrumParams(){

var spec = new NMRSpectrum( nmr.activeSpectrum() );var htmlText = "<b>Nucleus</b>: %1 <br/> <b>Frequency: </b> %2 <br/> <b>Pulse

Sequence: </b> %3 <br/> <b>psLabel: </b> %4 <br/> <b>Solvent: </b> %5 <br/> <b>Title: </b> %6";var nuc = spec.getParam("Nucleus[1]");var freq = spec.getParam("Spectrometer Frequency");var seqfill = spec.getParam("Pulse Sequence");var psLabel = spec.getParam("psLabel");var Solvent = spec.getParam("Solvent");var Title = spec.getParam("Title");print(spec.getParam("Nucleus[1]"));print(spec.getParam("Spectrometer Frequency"));print(spec.getParam("Pulse Sequence"));print(spec.getParam("psLabel"));print(spec.getParam("Solvent"));print(spec.getParam("Title"));htmlText=htmlText.arg(nuc).arg(freq).arg(seqfill).arg(psLabel).arg(Solvent).arg(Title);

draw.text(htmlText, true);}

In this case, the script will print the parameters Nucleus, Spectrum Frequency, Pulse Sequence,psLabel, Solvent and Title. Please bear in mind that getParam function returns only parameters whichexist in the table of parameters (including invisible ones). Please make sure that you have theseparameters included on the table of parameters (via customization dialog).

· NMRSpectrum: The NMRSpectrum objects allow us to get information about our spectra. Theobjects of type NMRSpectrum have the following properties:

Page 40: Scripting With Mnova 5.3.0

Mnova Scripting40

© 2009 MESTRELAB RESEARCH

NMRSpectrum page item Inherits PageItem

o property curSpecIndex: NumberGet/set current spectrum index of arrayed experiment. Indexing is zero-based.

o property dimCount: NumberNumber of dimensions

o property experimentType: Number

o property isReal: Boolean

o property originalFormat: StringValid values: {"ASCII", "Bruker Aspect", "Bruker WIN-NMR", "Bruker XWIN-NMR", "Elscint","GE/Nicolet", "JCAMP-DX", "JEOL Alice", "JEOL Delta", "JEOL EX/GX", "JEOL Lambda","Lumisys", "MestReC", "MNova", "Nuts Type 1", "Nuts Type 2", "Nuts Type 3", "Old Gemini","Predictor", "Siemens", "Spinsight", "SWANMR", "Techmag", "Unknown", "Varian", "VHelper"}

o property proc: NMRProcessing

o property solvent: String

o property specCount: NumberReturns number of spectra for arrayed experiments

o property temperature: Number

o property threshold: NumberThreshold

o property title: String

o constructor NMRSpectrum(NMRSpectrum aSpectrum)

§ NMRSpectrum aSpectrum

o function autoDetectNoiseRegions(): ArrayReturn a list of noise regions, only for 1D

o function corrPearson(NMRSpectrum aSpectrum): Number

§ NMRSpectrum aSpectrum

o function count(Number aDim): NumberNumber of points in the dimension aDim

§ Number aDim

o function count(): NumberNumber of points in the last dimension

o function fidImag(Number aIndex): NumberReturns the imag value of the aIndex point in the spectrum fid

§ Number aIndex

Page 41: Scripting With Mnova 5.3.0

41

© 2009 MESTRELAB RESEARCH

o function fidReal(Number aIndex): NumberReturns the real value of the aIndex point in the spectrum fid

§ Number aIndex

o function fidSetImag(Number aIndex, Number aValue): BooleanSets the imag value of the aIndex point in the spectrum fid

§ Number aIndex

§ Number aValue

o function fidSetReal(Number aIndex, Number aValue): BooleanSets the real value of the aIndex point in the spectrum fid

§ Number aIndex

§ Number aValue

o function fitToHeight()Fits spectrum intensity to height

o function frequency()

o function frequency(Number aDim)

§ Number aDim

o function getParam(String aParamName): Variant

§ String aParamName - Parameter name as it appears in the table of parameters. If theparameter is N-dimensional then specify the dimension in []. Example: getParam("Nucleus[2]")

See also: setParam

o function getProperty(String aParam): Variant

§ String aParam - See details

See also: setProperty

o function horzZoom(Number aFrom, Number aTo)Without parameters makes a full zoom

§ Number aFrom

§ Number aTo

o function hz(): Number

o function hz(Number aDim): Number

§ Number aDim

o function imag(Number aIndex): NumberReturns the imag value of the aIndex point in the spectrum data

§ Number aIndex

Page 42: Scripting With Mnova 5.3.0

Mnova Scripting42

© 2009 MESTRELAB RESEARCH

o function isFID(Number aDim): Boolean

§ Number aDim

o function isReadOnlyParam(String aParam): Boolean

§ String aParam

o function isValid(): BooleanIs a valid spectrum object

o function isValid(Number aDim): BooleanThis dimension is less than dimCount

§ Number aDim

o function multiplets(): MultipletsReturns the list of multiplets of the spectrum

o function nucleus(Boolean aHtml): String

§ Boolean aHtml

o function nucleus(Number aDim, Boolean aHtml): StringReturns the nucleus of the dimension, if aHtml is true uses html

§ Number aDim

§ Boolean aHtml

o function peaks(): PeaksReturns the list of peaks of the spectrum

o function process(NMRProcessing aProc): BooleanProcess the spectrum using aProc. Without parameter re-process the spectrum

§ NMRProcessing aProc

o function real(Number aIndex): NumberReturns the real value of the aIndex point in the spectrum data

§ Number aIndex

o function scaleWidth(Number aDim): Number

§ Number aDim

o function scaleWidth(): Number

o function setImag(Number aIndex, Number aValue): BooleanSets the imag value of the aIndex point in the spectrum data

§ Number aIndex

§ Number aValue

Page 43: Scripting With Mnova 5.3.0

43

© 2009 MESTRELAB RESEARCH

o function setMultiplets(Multiplets aMultipletList)

§ Multiplets aMultipletList

o function setParam(String aParamName, Variant aValue)Assigns specified value to the named parameter. This function only allows to alter user definedparameters.

§ String aParamName - Parameter name as it appears in the table of parameters. If theparameter is N-dimensional then specify the dimension in [].

§ Variant aValue

See also: getParam

o function setPeaks(Peaks aPeakList)

§ Peaks aPeakList

o function setProperty(String aParam, Variant aValue)

§ String aParam - See details

§ Variant aValue

See also: getProperty

o function setReal(Number aIndex, Number aValue): BooleanSets the real value of the aIndex point in the spectrum data

§ Number aIndex

§ Number aValue

o function toString(): String

o function vertZoom(Number aFrom, Number aTo)Without parameters makes a full zoom

§ Number aFrom

§ Number aTo

o function zero(Number aDim): Number

§ Number aDim

o function zero(): Number

o function zoom(Number aHFrom, Number aHTo, Number aVFrom, Number aVTo)Without parameters makes a full zoom

§ Number aHFrom

§ Number aHTo

§ Number aVFrom

Page 44: Scripting With Mnova 5.3.0

Mnova Scripting44

© 2009 MESTRELAB RESEARCH

§ Number aVTo

· Page: You will find below a list of the Page objects:

o Number leftDescription: Left margin of the page (mm)

o Number rightDescription: Right margin of the page (mm)

o Number topDescription: Top margin of the page (mm)

o Number bottomDescription: Bottom margin of the page (mm)

o Number widthDescription: Width of the page

o Number heightDescription: Height of the page

o Page ( Page aPage)

§ Page aPage

o function itemCount( String aType): return Number

§ String aType: Element TypeValid Values: { "Arrow" "Ellipse" "Rectangle" "Polygon" "Image" "Text" "NMR Spectrum""Molecule" "OLE Object" "Mass Spectrum" }

Description: This function returns the number of objects in the current page

o function itemCount( ): retrieves the number of elements currently displayed in the page.

o function item( Number aIndex, String aType): return

§ Number aIndex: Number of elements

§ String aType: Element Type

Description: Returns the item of the page

o function item( Number aIndex): return

§ Number aIndex: Number of the element

Description: Returns an item of the page

o function addItem( PageItem aPageItem): return

§ PageItem aPageItem: Item to be added

Description: this function adds an item to the page

o function update( ): return

Page 45: Scripting With Mnova 5.3.0

45

© 2009 MESTRELAB RESEARCH

Description: The update function will be used to refresh the page

o function toString( ): return String

· PageItem: Below you will find the list of the objects related with the item of a page.

Item of a pageInherited by: Molecule, NMRSpectrum, Text

o Number angleDescription: Width of the item

o Number bottomDescription: Returns the bottom margin of the item

o Number heightDescription: Height of the itemNumber

o leftDescription: Returns the left margin of the item

o String nameDescription: Type of the element (arrow, ellipse, rectangle, polygon, image, text, NMR spectrum,molecule, OLE Object or Mass spectrum")

o Number rightDescription: Returns the right margin of the item

o Number topDescription: Returns the top margin of the item

o String uuidDescription: The UUID structure defines Universally Unique Identifiers (UUIDs). UUIDs provideunique designations of objects such as interfaces, manager entry-point vectors, and client objects.A string UUID contains the character-array representation of a UUID. A string UUID is composedof multiple fields of hexadecimal characters. Each member has a fixed length, and fields areseparated by the hyphen character.

o Number widthDescription: Width of the element

o PageItem ( PageItem aPageItem)

§ PageItem aPageItem

o function toString( ): return String

o function setProperty( String aParamName, Variant aValue): return

§ String aParamName:

§ Variant aValue:

Description: The SetProperty sets the specified parameter with the corresponding value. In order tosee the list of the aParamName, please click here

o function getProperty( String aParamName, String aUnit): return Variant

Page 46: Scripting With Mnova 5.3.0

Mnova Scripting46

© 2009 MESTRELAB RESEARCH

§ String aParamName:

§ String aUnit: Valid Values: { "mm" "cm" "inches" }

Description: Retrieves parameter in the selected unit (mm, cm, inches). In order to see the list of theaParamName, please click here

o function update( ): return

Description: Redraw the item

· Peak: The Peaks objects allow us to get information about the chemical shift of the signals. Theobjects of type Peak have the following properties:

o Number intensityDescription: returns the intensity of the peak

o Number typeDescription: returns the type of the peak. Valid Values: { "Peak.Compound" "Peak.Artifact""Peak.Impurity" "Peak.Solvent" "Peak.CS_Ref" "Peak.Quantification_Ref" }

o Number kindDescription: returns the kind of the peak. Valid Values: { "Peak.Maximum" "Peak.Minimum" }

o Peak ( Peak aPeak)

§ Peak aPeak:

Description: Copy the peak

o Peak (Number aPos, Number aIntensity)

§ Number aPos:

§ Number aIntensity:

Description: to create a peak with a determined chemical shift (Number aPos) and intensity (NumberaIntensity)

o Peak (Number aPos, NMRSpectrum aSpectrum)

§ Number aPos:

§ Number NMRSpectrum aSpectrum:

Description: too add a peak at a chemical shift 'aPos' in a 1D-NMR spectrum. The intensity of the peakis refilled with the spectral data

o Peak (Number aPos1, Number aPos2, Number aIntensity)

§ Number aPos1:

§ Number aPos2:

§ Number aIntensity:

Description: to create a peak in a 2D-NMR spectrum with a determined chemical shift (Number aPos)and intensity (Number aIntensity)

Page 47: Scripting With Mnova 5.3.0

47

© 2009 MESTRELAB RESEARCH

o Peak (Number aPos1, Number aPos2, NMRSpectrum aSpectrum)

§ Number aPos1:

§ Number aPos2:

§ NMRSpectrum aSpectrum:

Description: too add a peak at a chemical shift 'aPos' in a 2D-NMR spectrum. The intensity of the peakis refilled with the spectral data

o function delta( Number aDim): return

§ Number aDim:

Description: returns the chemical shift value of the peak

o function delta( ): return

Description: returns the chemical shift value of the peak

o function toString( ): return

· Peaks: The Peaks objects allow us to get information about the Peak Picking. The objects of typePeak have the following properties:

o Number countDescription:

o Peaks ( )Description: Empty peak list

o Peaks ( Peaks aPeakList)

§ Peaks aPeakList:

Description:

o Peaks (NMRSpectrum aSpectrum, SpectrumRegion aRegion)

§ NMRSpectrum aSpectrum:

§ SpectrumRegion aRegion:

Description:

o function at( Number aDim): return Peak

§ Number aDim:

Description: Returns the peaks at the position aDim

o function sort( Boolean bAscending): return

§ Boolean bAscending:

Description: it sorts the peaks in ascending/descending order

o function sort( Boolean bHAscending, Boolean bVAscending): return

Page 48: Scripting With Mnova 5.3.0

Mnova Scripting48

© 2009 MESTRELAB RESEARCH

§ Boolean bHAscending:

§ Boolean bVAscending:

Description: it sorts the peaks in ascending/descending order. In 2D, the user can select a differentsort in each dimension.

o function clear( Number aIndex): return

§ Number aIndex:

Description: clear the peaks

o function removeAt( Number aIndex): return

§ Number aIndex:

Description: remove the peaks at a determined chemical shift

o function append( Peak aPeak): return

§ Peak aPeak:

Description: to add the peak to the list

o function toString( ): return

· PeakTable: The PeakTable objects allow us to get the table peaks.

o PeakTable ( PeakTable aPeakTable)

§ PeakTable aPeakTable:

o function spectrum( ): return

Description: returns the spectrum to which the peak table makes reference

o function toString( ): return

· Process: The Process object is used to start external programs

o function Process.execute(String aProgram, Array aArguments): Number§ String aProgram§ Array aArguments

Description: Starts the program aProgram with the arguments aArguments in a new process, waits forit to finish, and then returns the exit code of the process

o function Process.startDetached(String aProgram, Array aArguments): Boolean§ String aProgram§ Array aArguments

Description: Starts the program aProgram with the arguments aArguments in a new process, anddetaches from it. Returns true on success

· Rectangle: Rectangle page itemInherits PageItem

Page 49: Scripting With Mnova 5.3.0

49

© 2009 MESTRELAB RESEARCH

o constructor Rectangle(Rectangle aRectItem)

§ Rectangle aRectItem

o function toString(): String

· Serialization: is the process of converting an object into a form that can be readily transported.For example, open and save documents.

o Serialization ( Serialization aSerialization)

§ Serialization aSerialization

o function open( String aFileName): return Boolean

§ String aFileName: File Name

Description: this function is used to open a file

o function open( Array aFileNameList): return

§ Array aFileNameList

Description: Opens an array of files

o function save( String aFileName, String aFormat): return

§ String aFileName

§ String aFormatValid Values: { "mnova" "mnlt" "mncs" "pdf" "ps" "eps" "bmp" "jpg" "mrc" "txt""jcamp" "png" "ppm" "svg" "tiff" "xpm" "xbm" }

Description: Saves a document (different formats available).

o function toString( ): return String

· Settings: You will find below a list of the objects related with saving and reading settings:

o Settings ( Settings aSettings)

§ Settings aSettings

o function value( String aKey, Variant aDefaultValue): return Variant

§ String aKey: name of the key

§ Variant aDefaultValue: Default value if the key doesn't exist or can't be read

Description: Read the value of a settings key

o function setValue( String aKey, Variant aValue): return

§ String aKey: a Settings key

§ Variant aValue: value to be saved

o function toString( ): return

· SpectrumRegion: The SpectrumRegion objects allow us to define a region in the spectrum.

Page 50: Scripting With Mnova 5.3.0

Mnova Scripting50

© 2009 MESTRELAB RESEARCH

The objects of type SpectrumRegion have the following properties

o SpectrumRegion ( SpectrumRegion aSpectrumRegion)

§ SpectrumRegion aSpectrumRegion:

o SpectrumRegion ( Number aFrom, Number aTo)

§ Number aFrom:

§ Number aTo:

Description: limits of the spectrum in 1D-NMR

o SpectrumRegion ( Number aFrom1, Number aTo1, Number aFrom2, Number aTo2)

§ Number aFrom1:

§ Number aTo1:

§ Number aFrom2:

§ Number aTo2:

Description: limits of the spectrum in 2D-NMR

o function toString( ): return String

o function from( Number aDim): return

§ Number aDim:

Description: Returns the ‘from’ of the region in the aDim dimension

o function to( Number aDim): return

§ Number aDim:

Description: Returns the ‘to’ of the region in the aDim dimension

o function dim( ): return

Description: Dimension of the region

· Text:

Text page itemInherits PageItem

o property htmlText: String

o property plainText: String

o constructor Text(Text aTextItem)

§ Text aTextItem

o function toString(): String

· TextStream: The TextStream object provides an interface for reading and writing text to a file.Example scripts are present in the examples/scripts installation directory.

o property pos: Number

Page 51: Scripting With Mnova 5.3.0

51

© 2009 MESTRELAB RESEARCH

Gets/sets the file position corresponding to the current position of the stream. Returns-1 if an error occurso property precision: Number

Gets/sets the current real number precision, or the number of fraction digitsTextStream will write when generating real numberso property notation: Number

Gets/sets the real number notationValid Values: {TextStream.nScientific, TextStream.nFixed, TextStream.nSmart}

o Constructor TextStream(File aFile)§ File aFile

Description:Constructs a TextStream that operates on aFile

o Constructor TextStream(TextStream aStream)§ TextStream aStream

Description:Constructs a TextStream that is a copy of aStream

o function atEnd(): Boolean

Returns true if there is no more data to be read from the TextStream

o function write(Variant aParam1, ..., Variant aParamN): Boolean§ Variant aParam1§ ...§ Variant aParamN

Writes the arguments to the stream

o function readLine(): String

Reads one line of text from the stream and returns it

o function readString(): String

Reads a word from the stream and returns it. Words are separated by whitespace

o function readNumber(): Number

Reads a number from the stream and returns it

o function read(Number aMaxLen): String§ Number aMaxLen

Reads at most aMaxLen characters from the stream, and returns the data read as a String

o function readAll(): String

Reads the entire content of the stream, and returns it as a String

o function skipWhiteSpace()

Reads and discards whitespace from the stream until either a non-space character is detected, or untilatEnd() returns true

o function skip(Number aSize)§ Number aSize

Skips the aSize bytes in the stream

o function toString(): String

NMRProcessing. Describing Processing parameters (Argument Strings).

Page 52: Scripting With Mnova 5.3.0

Mnova Scripting52

© 2009 MESTRELAB RESEARCH

Below you will find a list of the argument strings (which have the formfunction1.function2...functionN.parameter) that you will be able to use in your processing scripts.These parameters appear in the graphical interface of the software (in the ‘Processing / FullProcessing’ menu) and are described in depth in the manual of Mnova (hyperlink a processing menu).

Page 53: Scripting With Mnova 5.3.0

53

© 2009 MESTRELAB RESEARCH

· Boolean Rev[aDimension]: Reverse

· Boolean Transpose:

· Boolean Tilt45:

· Boolean CosySym: Symmetrize COSY-like

· Boolean JResolv: Symmetrize JResolved

· Boolean Invert:

· Boolean Reducet1: Reduce t1 Noise

· Boolean Inadequate:

· function DC: Drift Correction

o Boolean Apply:

o Number Value: Number of tail points

Page 54: Scripting With Mnova 5.3.0

Mnova Scripting54

© 2009 MESTRELAB RESEARCH

Apodization

· function Apodization[aDimension]: Apodization

Apodization[].Apply: Boolean

Apodization[].ConDif.Apply: Boolean

Apodization[].ConDif.Value1: Number

Apodization[].ConDif.Value2: Number

Apodization[].ConDif.Value3: Number

Apodization[].Exp.Apply: Boolean

Apodization[].Exp.Value: Number

Apodization[].FP.Apply: Boolean

Apodization[].FP.Value: Number

Apodization[].Gauss.Apply: Boolean

Apodization[].Gauss.Value: Number

Apodization[].Han.Apply: Boolean

Apodization[].Han.Value: Number

Apodization[].Lg.Apply: Boolean

Apodization[].Lg.Value: Number

Apodization[].Lr.Apply: Boolean

Apodization[].Sine.Apply: Boolean

Apodization[].Sine.Value: Number

Apodization[].Sine2.Apply: Boolean

Apodization[].Sine2.Value: Number

Apodization[].Traf.Apply: Boolean

Apodization[].Traf.Value: Number

Apodization[].Trap.Apply: Boolean

Apodization[].Trap.Value: Number

· BC

Page 55: Scripting With Mnova 5.3.0

55

© 2009 MESTRELAB RESEARCH

Baseline Correction

· BC[].algorithm: StringValid values: {"Bernstein", "PolyFit", "Whittaker"}

· BC[].Apply: Boolean

· BC[].Filter: Number

· BC[].PolyOrder: Number

· BC[].Smooth: Number

· Binning

Binning

· Binning[].Apply: Boolean

· Binning[].From: Number

· Binning[].Full: Boolean

· Binning[].To: Number

· Binning[].Width: Number

· Comp

Compression

· Comp.Ratio: Number

· CosySym

· CosySym: Boolean

Cuts

· Cuts[].Apply: Boolean

· Cuts[].List: Array - Array of SpectrumRegion

DCDrift Correction

· DC.Apply: Boolean

· DC.Value: Number

Page 56: Scripting With Mnova 5.3.0

Mnova Scripting56

© 2009 MESTRELAB RESEARCH

DSDiagonal Supression

· DS.Apply: Boolean

· DS.Diagonal: StringValid values: {"Double", "Inverted", "Quad", "Std"}

· DS.Method: StringValid values: {"Convolution", "ShiftedConv", "Wavelet"}

· DS.Selectivity: Number

FTFourier Transform

· FT[].Hyper: Boolean

· FT[].Invert: Boolean

· FT[].Protocol: StringValid values: {"Echo-Antiecho", "Hyper", "None"}

· FT[].Quadrature: Boolean

· FT[].RealFT: Boolean

Inadequate

· Inadequate: Boolean

Integration

· Integration.Apply: Boolean

· Integration.Auto.AutoSensitivity: Boolean

· Integration.Auto.MergeDistance: Number

· Integration.Auto.MinArea: Number

· Integration.Auto.Sensitivity: Number

· Integration.Method: StringValid values: {"Auto", "Predefined"}

· Integration.regions: SpectrumRegionArray

Page 57: Scripting With Mnova 5.3.0

57

© 2009 MESTRELAB RESEARCH

Invert

· Invert: Boolean

JResolv

· JResolv: Boolean

LPLinear Prediction

· LP[].Backward.Apply: Boolean

· LP[].Backward.First: Number

· LP[].Backward.Last: Number

· LP[].BasisPoints: Number

· LP[].Coefficients: Number

· LP[].Forward.Apply: Boolean

· LP[].Forward.First: Number

· LP[].Forward.Last: Number

· LP[].method: StringValid values: {"Burg", "Debug", "Toeplitz", "ZhuBax"}

· LP[].size: Number

MultMultiplet Analysis

· Mult.Apply: Boolean

NormNormalize

· Norm.Apply: Boolean

· Norm.Method: StringValid values: {"LargestPeak", "Manual", "PeakPos", "PeakRange", "TotalArea"}

· Norm.PeakPos: Number

· Norm.Range: NumberArray

· Norm.Value: Number

Page 58: Scripting With Mnova 5.3.0

Mnova Scripting58

© 2009 MESTRELAB RESEARCH

PCPhase Correction

· PC[].Method: StringValid values: {"Global", "Magnitude", "Manual", "Metabonomics", "NoPC", "Power", "Selective"}

· PC[].Ph0: Number - In radians

· PC[].Ph1: Number - In radians

PPPeak Picking

· PP.Apply: Boolean

· PP.f1Max: Number

· PP.f2Max: Number

· PP.MaxPeaks: Number

· PP.MergeMult: Boolean

· PP.Parabolic: Boolean

· PP.PeakType: StringValid values: {"All", "Negative", "Positive"}

· PP.Sensitivity: Number

Reducet1

· Reducet1: Boolean

RefReference

· Ref[].Apply: Boolean

· Ref[].AutoTune: Boolean

· Ref[].shift: Number

· Ref[].Torerance: Number

RevReverse

· Rev[]: Boolean

Page 59: Scripting With Mnova 5.3.0

59

© 2009 MESTRELAB RESEARCH

SmoothSmooth

· Smooth[].Apply: Boolean

· Smooth[].Average.Span: Number

· Smooth[].Method: StringValid values: {"Average", "SG", "Wavelet", "Whittaker"}

· Smooth[].SG.Order: Number

· Smooth[].SG.Width: Number

· Smooth[].Wavelet.Fraction: Number

· Smooth[].Wavelet.Scales: Number

· Smooth[].Wavelet.Soft: Boolean

· Smooth[].Wavelet.Universal: Boolean

· Smooth[].Whittaker.AutoLambda: Boolean

· Smooth[].Whittaker.Lambda: Number

SSSignal Supression

· SS.Apply: Boolean

· SS.Method: StringValid values: {"Convolution", "ShiftedConv", "Wavelet"}

· SS.Selectivity: Number

· SS.Signals: NumberArray

Tilt45

· Tilt45: Boolean

TransposeTranspose

· Transpose: Boolean

TruncTruncate

Page 60: Scripting With Mnova 5.3.0

Mnova Scripting60

© 2009 MESTRELAB RESEARCH

· Trunc[].After: Number

· Trunc[].Apply: Boolean

ZFZero Filling

· ZF[].size: Number

Page 61: Scripting With Mnova 5.3.0

61

© 2009 MESTRELAB RESEARCH

1.4 Mnova Properties

Below you will find the spectrum properties (aParamName) that you can manage via script, by usingthe functions ‘SetProperty’ and ‘GetProperty’. You will find an example script in the examples/scriptsinstallation directory and also in the 'Script Samples' chapter. All of these properties can also beselected by using the GUI:

Page 62: Scripting With Mnova 5.3.0

Mnova Scripting62

© 2009 MESTRELAB RESEARCH

Axes

· axes.color: StringValid values: {"#RRGGBB", "Color Keywords"}

· axes.font: String

· axes.horizontal.label: String

· axes.horizontal.maxdigits: Number

· axes.horizontal.showlabel: Boolean

· axes.horizontal.units: StringValid values: {"hz", "ppm", "pt", "sec"}

· axes.margin.cm: Number

· axes.margin.inches: Number

· axes.margin.mm: Number

· axes.vertical.label: String

· axes.vertical.maxdigits: Number

· axes.vertical.showlabel: Boolean

· axes.vertical.units: StringValid values: {"hz", "ppm", "pt", "sec"}

Background

· background.color: StringValid values: {"#RRGGBB", "Color Keywords"}

· background.opacity: Number

Contours

· contours.negativenumber: Number

· contours.positivenumber: Number

· contours.scaling: Number

Curve

· curve.color: StringValid values: {"#RRGGBB", "Color Keywords"}

· curve.linestyle: String

Page 63: Scripting With Mnova 5.3.0

63

© 2009 MESTRELAB RESEARCH

Valid values: {"circles", "crosses", "line"}

· curve.linewidth: Number

Grid

· grid.color: StringValid values: {"#RRGGBB", "Color Keywords"}

· grid.showframe: Boolean

· grid.showhorizontal: Boolean

· grid.showover: Boolean

· grid.showtracesframe: Boolean

· grid.showvertical: Boolean

Integrals

· integrals.curve.color: StringValid values: {"#RRGGBB", "Color Keywords"}

· integrals.curve.margin: Number

· integrals.curve.maxheight: Number

· integrals.curve.shape: StringValid values: {"Ellipse", "Rectangle"}

· integrals.curve.show: Boolean

· integrals.label.color: StringValid values: {"#RRGGBB", "Color Keywords"}

· integrals.label.decimals: Number

· integrals.label.font: String

· integrals.label.margin: Number

· integrals.label.position: StringValid values: {"Curve", "Segment"}

· integrals.label.show: Boolean

· integrals.show: Boolean

Legend

· legend.show: Boolean

· legend.textwidth.cm: Number

Page 64: Scripting With Mnova 5.3.0

Mnova Scripting64

© 2009 MESTRELAB RESEARCH

· legend.textwidth.inches: Number

· legend.textwidth.mm: Number

· legend.width.cm: Number

· legend.width.inches: Number

· legend.width.mm: Number

Multiplets

· multiplets.decimals: Number

· multiplets.font: String

· multiplets.fontcolor: StringValid values: {"#RRGGBB", "Color Keywords"}

· multiplets.labelcolor: StringValid values: {"#RRGGBB", "Color Keywords"}

· multiplets.margin: Number

· multiplets.show: Boolean

Palette

· palette: String

Peaks

· peaks.color: String

· peaks.decimals: Number

· peaks.font: String

· peaks.pointer: StringValid values: {"Arrow", "Line", "None"}

· peaks.show: Boolean

· peaks.showtick: Boolean

· peaks.units: StringValid values: {"hz", "ppm"}

You will find below an example of a script to change some properties of your spectra. In this case, thecolour of the spectrum will be changed to red, the peaks font to Arial and the integral curves will beshowed.

function properties(){

Page 65: Scripting With Mnova 5.3.0

65

© 2009 MESTRELAB RESEARCH

var spec = new NMRSpectrum(nmr.activeSpectrum());

spec.setProperty("curve.color","red");spec.setProperty("peaks.font","Arial");spec.setProperty("integrals.curve.show", true);spec.update();mainWindow.activeWindow().update();

}

1.5 GUI Actions

You will find below the GUI actions that you will be easily able to run with an easy script. The scriptbelow will apply an "Auto Peak Picking" analysis:

function doActionTest(){mainWindow.doAction("nmrAutoPeakPicking");}

If you want to run any other action just replace the red action with any action of the the list below. Ofcourse, you can add to the script as many actions as you want.

NMR GUI Actions

nmrActiveDimF1: To select the Dimension F1nmrActiveDimF2: To select the Dimension F2nmrAlign: Align...nmrApodize: Apodization...nmrArrayedApplyProc: Apply the processing to all spectranmrArrayedBitmap: To change to bitmapnmrArrayedFromSelection: To stack the selected spectranmrArrayedOverlayed: To superimpose the stack spectranmrArrayedSingle: To select the active spectrumnmrArrayedStacked: StackednmrArrayedWhiteWashed: Whitewash StackednmrAssignLinked: LinkednmrAssignment107Ag: 107AgnmrAssignment109Ag: 109AgnmrAssignment10B: 10BnmrAssignment11B: 11BnmrAssignment129Xe: 129XenmrAssignment13C: 13CnmrAssignment14N: 14NnmrAssignment15N: 15NnmrAssignment17O: 17OnmrAssignment19F: 19FnmrAssignment1H: 1HnmrAssignment207Pb: 207PbnmrAssignment23Na: 23NanmrAssignment27Al: 27AlnmrAssignment29Si: 29SinmrAssignment2H: DnmrAssignment31P: 31PnmrAssignment37Cl: 37ClnmrAssignment63Cu: 63Cu

Page 66: Scripting With Mnova 5.3.0

Mnova Scripting66

© 2009 MESTRELAB RESEARCH

nmrAssignment65Cu: 65CunmrAssignment6Li: 6LinmrAssignment7Li: 7LinmrAutomaticPhaseCorrectionGlobal: Auto (Global Method)nmrAutomaticPhaseCorrectionMetabonomics: Auto (Metabonomics)nmrAutomaticPhaseCorrectionSelective: Auto (Selective Method)nmrAutoPeakPicking: AutomaticnmrBaselineCorrection: Baseline Correction...nmrBinning: Binning...nmrBitmapPlot: Bitmap PlotnmrCompare: Predict ComparenmrCompression: Compression...nmrContourPlot: Contour PlotnmrDeleteAllPeaks: Delete AllnmrDeleteCurrentIntegral: Delete IntegralnmrDeleteCurrentMultiplet: Delete MultipletnmrDiagonalSuppression: Diagonal Suppression...nmrDriftCorrection: Drift Correction...nmrEditIntegral: Edit Integral...nmrEditMultiplet: Edit Multiplet...nmrExtractActiveSpectrum: Extract Active SpectrumnmrExtractAllSpectra: Extract All SpectranmrFilterFalsePosJCor: Filter False PositivesnmrFitHorzTraceToHeight: Fit Horizontal Trace to HeightnmrFitTracesToHeight: Fit Traces to HeightnmrFitVertTraceToHeight: Fit Vertical Trace to HeightnmrFT: Fourier Transform...nmrFullAutoBaselineCorrection: Full AutonmrFullProcessing: Full Processing...nmrHighlightActiveSpec: Highlight Active SpectrumnmrHighPassFilter: Signal Suppression...nmrIntegrateAuto: Autodetect RegionsnmrIntegrateDeleteAll: Delete AllnmrIntegrateDeleting: Delete ManuallynmrIntegrateManual: ManualnmrIntegrateOptions: Options...nmrIntegratePredefined: Predefined RegionsnmrIntegrateShow: Show IntegralsnmrInvert: InvertnmrJCor: J-Correlator...nmrLinearCombination: Arithmetic...nmrMagnitude: MagnitudenmrManualPeakPicking: ManualnmrManualPhaseCorrection: Manual CorrectionnmrMultipletCopyC: Copy MultipletsnmrMultipletDeleteAll: Delete All MultipletsnmrMultipletReportC: Report MultipletsnmrMultipletsAuto: AutomaticnmrMultipletsDeleteAll: Delete AllnmrMultipletsManual: ManualnmrMultipletsShow: Show MultipletsnmrNormalize: Normalize...nmrPeakByPeak: Peak by PeaknmrPeakDeleting: Delete Manually

Page 67: Scripting With Mnova 5.3.0

67

© 2009 MESTRELAB RESEARCH

nmrPeakPickingCopy: CopynmrPeakPickingOptions: Options...nmrPeakPickingReport: ReportnmrPeaksShow: Show PeaksnmrPower: PowernmrPredictHighlight: PredictnmrPredictHighlightShow: Show HighlightingnmrReducet1Noise: Reduce t1 NoisenmrReference: ReferencenmrResEnh: Resolution Booster...nmrReverseBothAxes: Both AxesnmrReverseHorizontally: HorizontallynmrReverseVertically: VerticallynmrScaleArrayed: Scale Stacked Spectra...nmrSelectTraces: Select Traces GraphicallynmrSetupArrayed: Setup Stacked Spectra...nmrShowFT1: Spectrum after 1st FTnmrShowFT2: Spectrum after 2nd FTnmrShowHorzTrace: Show Horizontal TracenmrShowOriginalFID: Original FIDnmrShowProcessedFID: Processed FIDnmrShowTraces: Show TracesnmrShowVertTrace: Show Vertical TracenmrSmooth: Smoothing...nmrSpectralMoments1stOrder: First OrdernmrSpectralMoments2ndOrder: Second OrdernmrSpectralMomentsNone: Do Not ApplynmrStackedPlot: Stacked PlotnmrSuperimposedFromSelection: Superimpose SpectranmrSymmetrizeJResolved: J-ResolvednmrSymmetrizeRealSquareMatrix: COSY-likenmrTilt45: Tilt 45nmrTracesSetup: Setup...nmrTranspose: TransposenmrTruncate: Truncate...nmrVisualVerification: HSQCnmrVisVerShowAll: Show All RectanglesnmrVisVerShowGreens: Show Green RectanglesnmrVisVerShowReds: Show Red RectanglesnmrVisVerShowYellows: Show Yellow RectanglesnmrWhiteWashedPlot: Whitewash Stacked PlotnmrZeroFilling: Zero Filling and LP...

Draw GUI Actions

drwAlignCenter: CentereddrwAlignLeft: Align LeftdrwAlignRight: Align RightdrwFontBold: BolddrwFontItalic: ItalicdrwFontSubscript: SubscriptdrwFontSuperscript: Superscript

Page 68: Scripting With Mnova 5.3.0

Mnova Scripting68

© 2009 MESTRELAB RESEARCH

drwFontUnderline: UnderlinedrwModeArrow: ArrowdrwModeEllipse: EllipsedrwModeLine: LinedrwModePoly: PolygondrwModeRect: RectangledrwModeSelect: SelectdrwModeText: Text

NMR Predictor GUI Actions

nmr_predictor_Calculate13CSpectrum: Predict 13C Spectrumnmr_predictor_Calculate1HSpectrum: Predict 1H Spectrumnmr_predictor_PredictionOptions: Prediction Options...

MNova GUI Actions

You can also run this actions by scripting:

action_Customize_Toolbars: &Customize Toolbars... action_Edit_Copy: &Copy action_Edit_CreateNewPage: Create &New Page action_Edit_Cut: Cu&t action_Edit_Delete: &Delete action_Edit_Paste: &Paste action_Edit_PasteSpecial: Paste &Special action_Edit_Properties: Pr&operties... action_Edit_Redo: &Redo action_Edit_SelectAll: Select &All action_Edit_Undo: &Undo action_File_Exit: E&xit action_File_ExportToPDF: &Export to PDF... action_File_New: &New action_File_Open: &Open... action_File_Page_Setup: Page &Setup... action_File_Print: &Print... action_File_Save: &Save action_File_SaveAs: Save &As... action_Help_About: &About... action_Layout_Activate: Activate... action_Layout_Activated: Activated action_Layout_Show: Show action_Registration: Evaluate/Buy... action_RegistrationInfo: License Manager... action_View_Antialiasing: Antia&liasing action_View_Crosshair: Cross&hair action_View_Cut_auto: &Auto Cut action_View_Cut_cut: &Cut action_View_Cut_manual: &Manual Cuts action_View_Cut_resotoreAll: &Restore All

Page 69: Scripting With Mnova 5.3.0

69

© 2009 MESTRELAB RESEARCH

action_View_Cut_restore: &Restore action_View_DecIntensity: &Decrease Intensity action_View_Fit2Height: &Fit to Height action_View_FullView: &Full View action_View_History: &History... action_View_IncIntensity: &Increase Intensity action_View_LargeIcons: Large &Icons action_View_NextPage: Ne&xt Page action_View_Pan: &Pan action_View_PreviousPage: Pre&vious Page action_View_Rulers: &Rulers action_View_Tables_Close_All: Close &All action_View_Zoom_FullSpec: &Full Spectrum action_View_Zoom_in: Zoom &In action_View_Zoom_Manual: &Manual Zoom action_View_Zoom_out: Zoom &Out actionAlignBottom: Align Bottom actionAlignCenterHorz: Center Horizontally actionAlignCenterVert: Center Vertically actionAlignLeft: Align Left actionAlignPaperCenter: Center on Page actionAlignPaperCenterHorz: Center on Page Horizontally actionAlignPaperCenterVert: Center on Page Vertically actionAlignRight: Align Right actionAlignTop: Align to Top actionBringDown: Send Down actionBringToBack: Send to Back actionBringToFront: Bring to Front actionBringUp: Bring Up actionCustomize_Context_Menus: Customize Context Menus... actionTileHorizontally: Tile &Horizontally actionTileSpectraHorizontally: Tile Spectra Hori&zontally actionTileSpectraVertically: Tile Spectra Ve&rtically actionTileVertically: Tile &Vertically

Another example of this tool to apply several actions to all the spectra opened in the same document:

Page 70: Scripting With Mnova 5.3.0

Mnova Scripting70

© 2009 MESTRELAB RESEARCH

This script will generate a stack plot of all the opened spectra. You can use this script to run whatever doAction you desired, just by changing the name into the brackets.

1.6 Running Scripts from the command line

It is possible to run scripts from the command line, just by typing the path where the Mnova .exe fileand the script are located and -sf "name of the script function": "mestrenovaPathname""scriptPathname" -sf "scriptFunctionToRun"

For example:

1. mestrenova scriptPathFor example: mestrenova c:\temp\multiOpen.qs will run the function multiOpen() from multiOpen.qsfile, i.e. it runs a function with the same file name.

2. mestrenova scriptPath -sf functionName,arg1,arg2,...,argNThis runs functionName(arg1, arg2, ... argN) from the scriptPath file.

The below command line is doing the same as the above one: mestrenova -sf functionName,arg1,arg2,...,argN scriptPath

Examples:You can also use: "mestrenovaPath" "scriptPath" -sf "scriptFunctionToRun"

"C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe" "C:\Program Files\Mestrelab Research S.L\MestReNova\scripts\myScript.qs" -sf "myFunction"It is also possible to specify arguments:

"C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe" "C:\Program Files\Mestrelab Research S.L\MestReNova\scripts\myScript.qs" -sf "myFunction",0.1,10,true,off

In this case, MNova will run myFunction(0.1,10,true,"off") from myScript.qs with the arguments

Page 71: Scripting With Mnova 5.3.0

71

© 2009 MESTRELAB RESEARCH

specified. No spaces after commas!

3. mestrenova -sf functionName,arg1,arg2,...argN

In this case it is supposed that the function functionName is taken from one of the script directories,either MNova standard or user defined.

Note: Command line arguments are separated with white-spaces. This is why it is important not to usewhite-spaces after commas. If script arguments contain white-spaces then use quotes: "C:\ProgramFiles\Mestrelab Research S.L\MestReNova\MestReNova.exe" -sf openSpecWithMols,"C:\1H\fid".

This doesn't need quotes: "C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe"-sf openSpecWithMols,C:\1H\fid

Complex case example:mestrenova specPath1 specPath2 -sf functionName,arg1,arg2 specPath3 specPath4

This will first open the spectra specPath1, specPath2, specPath3, specPath4. Next, apply the script:functionName(arg1, arg2)

1.7 Scripts Samples

Other Scripts samples:All the scripts are present in the examples/scripts installation directory. Some of them will be describedin this chapter. Please bear in mind that it is also possible to run scripts from the command line, just bytyping the path where the Mnova .exe file and the script are located and -sf "name of the scriptfunction": "mestrenovaPathname" "scriptPathname" -sf "scriptFunctionToRun"

For example:

"C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe" "C:\Program Files\Mestrelab Research S.L\MestReNova\scripts\myScript.qs" -sf "myFunction"It is also possible to specify arguments:

"C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe" "C:\Program Files\Mestrelab Research S.L\MestReNova\scripts\myScript.qs" -sf "myFunction",0.1,10,true,off

In this case, MNova will run myFunction(0.1,10,true,"off") from myScript.qs with the argumentsspecified. No spaces after commas!

Do not forget to visit our script repository at: http://www.mestrec.com/recursos.php?idc=11&i18n=1

Open and Save Document Script: Let´s take a look at an easy script which you can use to open a .mnova file and export it as a PDF file. In this case, we will open a .mnova file named 'Dimethoxy':

function openSaveDocument(){

//If the open function gives a 'false', it will mean that Mnova does not recognize the fileif( serialization.open("/dimethoxy.mnova") ){

print("File Opened");//Let´s see what the document contains//To get the active documentvar dW = new DocumentWindow(Application.mainWindow.activeWindow());//To get information about the number of the pages of the documentprint(dW.pageCount());//To print the number of items and the description of them for each page

Page 72: Scripting With Mnova 5.3.0

Mnova Scripting72

© 2009 MESTRELAB RESEARCH

for( var i = 0; i < dW.pageCount(); i++ ){

var pag = new Page(dW.page(i));print ( "Page number "+i+" has "+pag.itemCount()+" items" );for( var j = 0; j < pag.itemCount(); j++ ){

var item = new PageItem(pag.item(j));print( "\t"+item.name );//If the item is an NMR spectrum, it will print "This is an NMR

spectrum", if not, the function isValid will give a "False"var spectrum = new NMRSpectrum(item);if(spectrum.isValid() )

print( "This is an NMR Spectrum" );}

}//To save as a PDF fileserialization.save("/dimethoxy.pdf", "pdf");

}}

To run this script, just copy it to the 'Edit Script' dialog box and type "openSaveDocument()" in thecombobox. Please bear in mind that, you will need to write the corresponding path of the saved Mnovafile in the line 4 of the script (in this case the dimethoxy.mnova file was saved in C:\ ).As you can see in the script, if Mnova does not recognize the spectrum, you will obtain a 'False'message in the output due to the statement: if( serialization.open("/dimethoxy.mnova") )

The line print("File Opened"); will give the corresponding message in the output, as you can see in thepicture below:

Page 73: Scripting With Mnova 5.3.0

73

© 2009 MESTRELAB RESEARCH

The object 'Application' of the variable var dW = new DocumentWindow(Application.mainWindow.activeWindow()); gives us the 'Active Window' of the 'Main Window', that is to say, the document whichwe can see in the screen. The function print(dW.pageCount()); is used to know the number of thepages of the document.

The following lines of the script are used to obtain information about the items included on thedocument. For example the function pageCount is used to know the number of pages of thedocument. The variable var pag = new Page(dW.page(i)); will analyze page by page to find theinformation. The line print ( "Page number "+i+" has "+pag.itemCount()+" items" ); will print thecorresponding phrase in the output, following the number of the page (+i+) and the number of theitems included in the page for( var j = 0; j < pag.itemCount(); j++ ). The variable var item = new

Page 74: Scripting With Mnova 5.3.0

Mnova Scripting74

© 2009 MESTRELAB RESEARCH

PageItem(pag.item(j)); will inform about the type of the item, and the function print( "\t"+item.name );will print the name of the item. In this example (as we can see in the output of the picture below), thedocument has 2 pages; page 0 has 1 item, which is an NMR spectrum and page 1, has 5 items (NMRSpectrum, molecule, arrow, rectangle and ellipse).

The variable var spectrum = new NMRSpectrum(item); will rebuild the active spectrum, and if theitem is an NMR spectrum, it will print "This is an NMR spectrum", if not, the function isValid will give a"False" due to the lines: if(spectrum.isValid() ) // print( "This is an NMR Spectrum" );.

Finally, the plugin serialization.save("/dimethoxy.pdf", "pdf"); will save the document as a PDF file inthe specified location of the hard-disk (in this case, the PDF will be saved in C:\).

Open a spectrum with molecules:It is possible to open spectra with molecules by using the openSpecWithMols.qs example script. Youwill need to add the directory where you have the script to the ‘Scripts directories’ (by using the ‘Scriptmenu’). Then restart Mnova and you will be able to run the script from the command line by typing:“MestReNova path” –sf openSpecWithMols,”Spectrum path”

For example:

"C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe" -sfopenSpecWithMols,"C:\1H\fid"

Where, the yellow is the path where you have installed Mnova and the red is the path of the spectrumthat you want to open.

// Opens a spectrum at aSpecPath and all the molfiles located in the same directoryfunction openSpecWithMols(aSpecPath){var dirPath = File.absDirPath(aSpecPath);var dir = Dir(dirPath);dir.cdUp();var files = getMaskFiles(dirPath, dir.absPath, "*.mol", "*", false);files.push(dirPath);serialization.open(files);}

Import_Process_Save_Loop Script: This script can be used to apply a previously existing 'fullprocessing' template (in this case, it is a template saved at C:/temp/proc.mnp) to several spectra(saved at C:/spectra/ and inside sub-folders with the extension ".fid", for example: "C:/spectra/1H.fid")and to save the result in different files formats (.mnova, .pdf and .txt). This script in only valid for thesespectra containing a FID file.

/******************************************************************************************************Copyright (C) 2007 Mestrelab Research S.L. All rights reserved.

This file is part of the MNova scripting toolkit.

Authorized users of MNova Software may use this file freely, but this file is provided AS ISwith NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN,MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE.*****************************************************************************************************/// This example function demonstrates how to apply some processing to a set of spectral files and tosave the result in the different file formats.function import_process_save_loop()

Page 75: Scripting With Mnova 5.3.0

75

© 2009 MESTRELAB RESEARCH

{const dirName = "c:/spectra"; // Source directory with spectra to be processed.const resultDirName = dirName; // Destination directory where processed spectra should be

put.const procName = "c:/temp/proc.mnp"; // Processing file. It must be created in the Full

Processing dialog of MestReNova.const fileMask = "fid"; // This mask specifies files to be processed. const dirMask = "*.fid"; // This mask specifies directories to be scanned for spectra.

var dir = new Dir(dirName);if (!dir.exists){

MessageBox.critical("Directory " + dirName + " does not exist.",MessageBox.Ok);return;

}dir.cdUp();

// The below function getMaskFiles is located in the files.qs script. // If you run import_process_save_loop from QSA Workbench then it is necessary to introduce

getMaskFiles to the interpreter by importing files.qs.var files = getMaskFiles(dirName, dir.absPath, fileMask, dirMask, true); for(var i = 0; i < files.length; i++){

var dw = new DocumentWindow(Application.mainWindow.newWindow()); //Create new document window

if (serialization.open(files[i])){

nmr.process(procName);const toReplace = new RegExp("[/|:]", "g"); fileName = resultDirName + "/" + files[i].replace(toReplace, "_"); // Generate a

filename for processed spectrum. serialization.save(fileName+".mnova", "mnova"); // MestReNova file formatserialization.save(fileName+".pdf", "pdf"); // Adobe PDF file formatserialization.save(fileName+".txt", "ascii"); // ASCIIprint(fileName); // Prints file name in the debug window

}dw.close(); // Close document window of processed spectrum

}}

Parameters Script: This script can be used to obtain the desired parameters on your spectrum. Youwill be able to add or remove any parameter and to change the font by just using HTML code.

function spectrumParams(){

var spec = new NMRSpectrum( nmr.activeSpectrum() );var htmlText = "<b>Nucleus</b>: %1 <br/> <b>Frequency: </b> %2 <br/> <b>Pulse

Sequence: </b> %3 <br/> <b>psLabel: </b> %4 <br/> <b>Solvent: </b> %5 <br/> <b>Title: </b> %6";var nuc = spec.getParam("Nucleus[1]");var freq = spec.getParam("Spectrometer Frequency");var seqfill = spec.getParam("Pulse Sequence");var psLabel = spec.getParam("psLabel");var Solvent = spec.getParam("Solvent");var Title = spec.getParam("Title");

Page 76: Scripting With Mnova 5.3.0

Mnova Scripting76

© 2009 MESTRELAB RESEARCH

print(spec.getParam("Nucleus[1]"));print(spec.getParam("Spectrometer Frequency"));print(spec.getParam("Pulse Sequence"));print(spec.getParam("psLabel"));print(spec.getParam("Solvent"));print(spec.getParam("Title"));htmlText=htmlText.arg(nuc).arg(freq).arg(seqfill).arg(psLabel).arg(Solvent).arg(Title);

draw.text(htmlText, true);}

In this case, the script will print the parameters Nucleus, Spectrum Frequency, Pulse Sequence,psLabel, Solvent and Title. Please bear in mind that getParam function returns only parameters whichexist in the table of parameters (including invisible ones). Please make sure that you have theseparameters included on the table of parameters (via customization dialog).

Fid Test Script: you will get information about the real and the imaginary part of the FID by runningthis script:

function fidTest(){

var spec = new NMRSpectrum( nmr.activeSpectrum() );print(spec.fidImag(0));if( spec.fidSetImag(0,0) )

print(spec.fidImag(0));print(spec.fidReal(0));

if(spec.fidSetReal( 0, 0 ) )print(spec.fidReal(0));

spec.process();mainWindow.activeWindow().update();

}

The command print(spec.fidImag(0)) will return the value of the imaginary part of the FID at theaIndex point (in this case; 0. You can type any number from zero to the number of points of yourspectrum), whilst the line print(spec.fidReal(0)); will give you the value of the real component. Theobject fidsetImag; sets the imaginary value of the aIndex point of the spectrum fid.

Integral Test Script: This script can be used to get information about the integrals of the spectrum:

function integralTest(){

var spec = new NMRSpectrum( nmr.activeSpectrum() );var intList = new Integrals(spec.integrals());print(intList);print(intList.count);print(intList.normValue);

var myInt = new Integral(intList.at(0));print(myInt);print(myInt.rangeMax(1));print(myInt.rangeMin(1));if( spec.dimCount > 1 ){

print(myInt.rangeMax(2));print(myInt.rangeMin(2));

}

Page 77: Scripting With Mnova 5.3.0

77

© 2009 MESTRELAB RESEARCH

print("Integral Value "+myInt.integralValue());print("Normalized value "+myInt.integralValue(intList.normValue));

var sReg = new SpectrumRegion(7.2, 7.5);var newInt = new Integral( spec, sReg, false );print(newInt);print(newInt.integralValue());spec.integrals().append(newInt);spec.process();

}

The first part of the script is used to count the integrals and to report the normalized value applied tothe integrals (in the list 'intList'). With the second part of the script, the user is able to select anyintegral of the list (in this case the integral which appears in the first position, if we wanted to select thesecond integral, we should have to type var myInt = new Integral(intList.at(1));). Then the scriptsreturns the absolute value and the limits of the selected integral. The third part of the script returns theabsolute and the normalized value of the integral.

The last part of the script can be used to add a new integral to the list (in this case an integral with thespectral region from 7.2 to 7.5 ppm). the script reports the absolute value of this integral.

Multiplet Test Script: This script is valid to obtain information about the multiplets of the spectrumand also to apply a 'manual multiplet analysis':

function multipletTest(){

var spec = new NMRSpectrum( nmr.activeSpectrum() );print(spec.multiplets());var sMult = new Multiplets(spec.multiplets());print(sMult.count);print(sMult.at(2));

var sReg = new SpectrumRegion(7.0, 7.5);var mult = new Multiplet( spec, sReg );var myMultiplets = new Multiplets();myMultiplets.append( mult );

var mult2 = new Multiplet( spec, new SpectrumRegion(3.80,3.90) );myMultiplets.append( mult2 );

var nM = new Multiplet(new SpectrumRegion(3.65,3.75), "t");nM.name="My mulltiplet";myMultiplets.append(nM);

print(myMultiplets);spec.setMultiplets(myMultiplets);print(spec.multiplets());spec.process();

}

The first part of the script creates a list of the multiplets which appear on the spectrum and printssome information about the selected multiplet (in this case, the multiplet number 2, but of course youcan select any other multiplet). The second part of the script creates a multiplet in the selected region'sReg' (in this case the region is 7.0-7.5 ppm. It works as a manual multiplet analysis). Then, itcreates a new empty list of multiplets which is added.

The third part of the script consists in a new region (from 3.80 to 3.90 ppm) to apply the multiplet

Page 78: Scripting With Mnova 5.3.0

Mnova Scripting78

© 2009 MESTRELAB RESEARCH

analysis. The following part of the script is used to add a multiplet manually to the multiplet list (theuser will be able to remove this part of this script without any problem). In this case, we wanted to adda triplet, which appears in the region from 3.65 and 3.75 ppm, with the name 'My multiplet'.

The end of the script is used to replace the original multiplet list for the list which we have justcreated.

Peak Test Script: A similar script used to obtain information about the chemical shift and theintensity of the peaks of a 1D-NMR spectrum:

function peakTest(){

var spec = new NMRSpectrum( nmr.activeSpectrum() );var sR = new SpectrumRegion( 0, 9.5 ); var ps = new Peaks(spec, sR); //fill the list with the peaks in sRprint(ps);var p = new Peak(1.265, spec);print(p);ps.append(p);spec.setPeaks(ps);//Set the peaks to psprint( spec.peaks());spec.process();

}

After running this script, we will get the peak picking analysis of a 1D-NMR spectrum from 0 to 9.5ppm (of course, we will be able to change this range). Then, a new peak at 1.265 ppm will be addedto the peak list (again, you can add any other peak, if you want), reporting the intensity value of thisnew peak. Finally, the spectrum will be re-analyzed to obtain the new number of peaks.

A similar script can be used for a 2D-NMR spectrum, but in this case we have to type thecorresponding spectrum region in 2D mode:

function peakTest(){

var spec = new NMRSpectrum( nmr.activeSpectrum() );var sR = new SpectrumRegion(4.0, 3.5, 75, 65 ); var ps = new Peaks(spec, sR); //fill the list with the peaks in sRprint(ps);var p = new Peak(72.73, 3.17, spec);print(p);ps.append(p);spec.setPeaks(ps);//Set the peaks to psprint( spec.peaks());spec.process();

}

Multiplet Reporter script: Let´s take a look now at a very important part of the 'Multiplet Reporter'script:

// This function defines JACS-like multiplet report.// To customize report, edit this class or implement another one.function JACSMultipletReporter(){MultipletReporter.call(this);

this.onlyElementName=false;

Page 79: Scripting With Mnova 5.3.0

79

© 2009 MESTRELAB RESEARCH

// Define font size and font familythis.font = "<font style=\"font-size: 10pt; font-family: Times New Roman\">";

this.nucleusTemplate="%1";// Report header. %1 will be replaced with nucleusString, %2 with frequency, %3 with solvent this.header = "%1 NMR (%2 MHz, %3) &delta; ";

// Multiplet templates. %1 - delta, %2 - category, %3 - nHthis.reportRange = true; // set to true to get multiplet range instead of delta.this.withoutJsTemplate = " %1 (%2, %3H)"; // multiplet template without J'sthis.withJsTemplate = " %1 (%2, %4, %3H)"; // multiplet template with J'sthis.rangeTemplate = "%1 &ndash; %2";

// J's list template. %1 - list of J'sthis.jListTemplate = "<i>J</i> = %1";

this.jPrecision = 1; // J's precisionthis.deltaPrecision = 2; // delta precisionthis.mSeparator = ", "; // multiplet separator this.jSeparator = ", "; // J's separator

this.start = this.font;this.end = ".</font>";}

JACSMultipletReporter.prototype = new MultipletReporter();JACSMultipletReporter.prototype.toString = function() { return "JACSMultipletReporter()"; }

(...)

The user will be able to change the multiplet report template to obtain the desired multiplet report; forexample:

this.onlyElementName=false; changing false with true, we will obtain only the element name withoutthe atomic mass (For example: H, C instead of 1H, 13C).

The function: this.font = "<font style=\"font-size: 10pt; font-family: Times New Roman\">"; will definethe font size and the font family of the multiplet report.

The line: this.header = "%1 NMR (%2 MHz, %3) &delta; "; is used to print the header of the report,where %1 will be the nucleus (H or C), %2 the frequency of the spectrometer (in MHz), and %3 thesolvent, followed by a delta symbol (d). For example: "1H NMR (500 MHz, CDCl3) δ".

The sentence: this.reportRange = true is used to obtain the multiplet range instead of the chemicalshift.

The functions: this.withoutJsTemplate = " %1 (%2, %3H)" and this.withJsTemplate = " %1 (%2, %4,%3H)" are used to customize the appearance of the multiplet report by changing the positions of %1,%2, %3H, or %4 (where, %1 means: chemical shift; %2 means: type of multiplet (s, d, t, etc); %3Hmeans: number of hydrogens and %4 means the coupling constant value). As you can see, the firstline shows a multiplet without coupling constants, (while the last line shows a multiplet with couplingconstants).

So, if you need to obtain something like this (Japanese format):

Page 80: Scripting With Mnova 5.3.0

Mnova Scripting80

© 2009 MESTRELAB RESEARCH

1H NMR (300 MHz, Solvent) d ppm 6.43-6.22 (1 H, m), 3.17 (1 H, q, J = 7.15 Hz) etc…

You should modify both lines, as you can see below:

this.withoutJsTemplate = %1 (%3H, %2)"; this.withJsTemplate = " %1 (%3H, %2, %4)";

If you prefer to obtain something like this:

1H NMR (300 MHz, Solvent) d ppm 1.23 (d, J = 1.2 Hz, 3 H), etc…

Just replace the original lines with:

this.withoutJsTemplate = %1 (%2, %3H)"; this.withJsTemplate = " %1 (%2, %4, %3H)";

To obtain the coupling constant symbol in normal instead of ‘italic’, just modify the script by removingthe italic format (<i>J</i>). If you prefer to obtain it in "bold" just type:

this.jListTemplate = "<b>J</b> = %1";

The following paragraph will be used to customize the appearance of the coupling constants list:

this.jPrecision = 1; // J's precisionthis.deltaPrecision = 2; // delta precisionthis.mSeparator = ", "; // multiplet separator this.jSeparator = ", "; // J's separator

The first line is used for the precision of the coupling constants values, the second will be used for theprecision of the chemical shift and the remaining two lines will print the separation between themultiplets and the coupling constants values.

If you need to obtain the coupling constants in descending order, replace 'true' with 'false' in thefollowing line:

var jList = new JList(multiplet.jList()); jList.sort(true);

If you want to obtain the multiplet chemical shifts in ascending order, just replace the 'false' with 'true'in the script:

var multiplets = new Multiplets(spectrum.multiplets()); // get multiplets fromspectrum jList.sort(true);

To obtain the multiplet range in ascending order, just replace the rangeMin with rangeMax (and viceversa) in the line below of the script:

shiftStr = this.rangeTemplate.argDec(multiplet.rangeMax, 0, 'f', this.deltaPrecision).argDec(multiplet.rangeMin, 0, 'f', this.deltaPrecision);

Page 81: Scripting With Mnova 5.3.0

81

© 2009 MESTRELAB RESEARCH

Title and Solvent: running this script, you will get the title and the solvent on your spectrum

// <GUI menuname="title1" shortcut="Ctrl+2" tooltip="Title_and_Solvent"/>function title1(){//To get the active spectrum

var spectrum = nmr.activeSpectrum();//The function isValid informs about if the spectrum obtained iscorrect

print( spectrum.isValid() ); var tit = draw.text("<h3>"+ spectrum.title+""+spectrum.solvent+"</h3>", true); }

Zoom: This script can be used to apply a zoom into a selected range of a spectrum. In order to selectthe horizontal range, just type the desired values between the brackets on the line spc.horZoom(1.0, 5.0);

If you want to set the vertical zoom, just change the values of the line spc.vertZoom(-100, 7000)

function spectrumZoom(){

var spc = nmr.activeSpectrum();if( !spc.isValid() )

return;spc.horZoom(1.0, 5.0);spc.vertZoom(-100, 7000);spc.update();mainWindow.activeWindow().update();

}

Properties Script: You will find below a script example to change some properties of your spectra. Inthis case, the colour of the spectrum will be changed to red, the peaks font to Arial and the integralcurves will be showed. You will find all the available properties at the 'Mnova Properties' chapter:

function properties(){

var spec = new NMRSpectrum(nmr.activeSpectrum());

spec.setProperty("curve.color","red");spec.setProperty("peaks.font","Arial");spec.setProperty("integrals.curve.show", true);spec.update();mainWindow.activeWindow().update();

}

Cutting: This script can be used to apply cuts to the spectra. You will obtain two cuts in yourspectrum, between 1.0-3.5 and 7.0-8.0 ppm respectively.

function myProcess(){var spec = new NMRSpectrum( nmr.activeSpectrum() );var p = new NMRProcessing(spec.proc);

Page 82: Scripting With Mnova 5.3.0

Mnova Scripting82

© 2009 MESTRELAB RESEARCH

var regs = new Array(2);regs[0] = new SpectrumRegion(1.0, 3.5);regs[1] = new SpectrumRegion(7.0, 8.0);print(p.getParameter("cuts"));p.setParameter("cuts.apply", true);p.setParameter("cuts.list", regs);spec.proc = p;spec.process();mainWindow.activeWindow().update();}

Magnitude Active Spectrum script: Let´s see another script; in this case this script is used to obtainthe 1D-NMR spectra in magnitude. Just open a 1D-NMR spectrum in Mnova, load this script byfollowing the menu 'Script/Edit Script', type "magnitudeActiveSpectrum()" in the edit box and click onthe green triangle to run the Script. You will obtain automatically your 1D-NMR spectrum in magnitude.

Please bear in mind that it is also possible to run scripts from the command line, just by typing the pathwhere the Mnova .exe file and the script are located and -sf "name of the script function": "mestrenovaPathname" "scriptPathname" -sf "scriptFunctionToRun"

For example:

"C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe" "C:\Program Files\Mestrelab Research S.L\MestReNova\scripts\magnitudeActiveSpectrum.qs" -sf"magnitudeActiveSpectrum"

Page 83: Scripting With Mnova 5.3.0

83

© 2009 MESTRELAB RESEARCH

Threshold Script: This script will allow the user to adjust the threshold of the color scheme in 2D-NMR spectra:

// <GUI menuname="threshold2D" shortcut="Ctrl+T" tooltip="threshold2D" />function threshold2D(){ var spectrum = nmr.activeSpectrum(); if(!spectrum.isValid() ) return

var th = spectrum.threshold;

Page 84: Scripting With Mnova 5.3.0

Mnova Scripting84

© 2009 MESTRELAB RESEARCH

var dlg = new Dialog(); dlg.title = "Threshold";

var edit = new LineEdit(); edit.label = "Threshold"; edit.text = th; dlg.add(edit); if (dlg.exec()) { spectrum.threshold = edit.text; } spectrum.update();

mainWindow.activeWindow().update();}

Running this script will show the 'Threshold' dialog box. From this window, the user will be able toadjust the threshold of the colour scheme by just typing the desired value and clicking on the 'OK'button.

ProcessTest Script: This script can be used to get some data from Mnova, save it as a file, next runsome external program in order to make calculations (or whatever you need) and once the externalprogram finishes, Mnova will get the result from another file. In this case the external program is the'NotePad'.

function processTest(){

fileName = Dir.temp() + "MNova_Process_Text.txt";var f = new File(fileName);f.open(File.WriteOnly);var s = TextStream(f);s.write("Hello Notepad!");f.close();print(Process.execute("notepad.exe", fileName));

f.open(File.ReadWrite);s.pos = f.size;print(s);s.write("\r\nHi again!");f.close();print(Process.startDetached("notepad.exe", fileName));

}

MultiOpen script: Mnova incorporates a script named 'MultiOpen'. This tool is very useful if, forexample, you always process your spectra in the same way, or when you have to routinely handle alarge number of datasets.

Page 85: Scripting With Mnova 5.3.0

85

© 2009 MESTRELAB RESEARCH

A practical example:

'multiopen script' allows to open simultaneously a collection of several spectra. Make sure that allspectra are located in the same folder. After that, select 'Run Script...' on the 'Script Menu' or click on

the 'Run Script' icon on the toolbar and then click 'Ok' after finding the corresponding script (inthis case, the script is called 'multiOpen'). Then, select the directory where the spectra are located anda window like the one below will open:

Finally, write the 'File Mask' name (you can use wildcards, so this could be, for example, '*', '???', fid or

Page 86: Scripting With Mnova 5.3.0

Mnova Scripting86

© 2009 MESTRELAB RESEARCH

ser), tick 'Recursively' and click 'OK'. All selected spectra will open simultaneously.

The user can also use the 'Full Processing' command to automate the processing of both 1D & 2DNMR data sets. (You can find a full description of this tool further on in the Automated Processingchapter.)

More complex scripts:

You will find below some complex scripts which we hope that you will find them useful for bathprocessing. You can copy the scripts directly from the manual or get them from our 'Script Repository'.

APF: this script will be used to apply a 'Processing template' (in this case saved in C:\) and format thecurrently opened spectrum by changing the position of the spectrum, adding a logo (saved in C:\),changing the 'zoom range', displaying the title and the solvent and a few parameters at the right side ofthe spectrum to obtain something like this:

You will find below the script used to obtain the above spectrum:

//<GUI menuname="APF" tooltip="Auto Process and Layout A Spectrum"/>/******************************************************************************************************Copyright (C) 2008 Mestrelab Research S.L. All rights reserved.This script is created for automatically processing and formatting the currently opened spectrum. Authorized users of MNova Software may use this file freely, but this file is provided AS ISwith NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN,MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE.*****************************************************************************************************/

Page 87: Scripting With Mnova 5.3.0

87

© 2009 MESTRELAB RESEARCH

function APF(){// Processing file. It must be created using the Full Processing dialog of MestReNova.// Change this to your actual path where this file is located.

const procFile = "C:/H1-Varian.mnp"; // Company Logo file. Change this to your actual file path:

const logoFile = "C:/MestreLab-logo.jpg";

// Load the logo file: serialization.open(logoFile);

// Reprocess the spectrum using the processing parameter file: // nmr.process(procFile);

// Now change the layout of the objects: var w = new DocumentWindow(Application.mainWindow.activeWindow());var p = new Page(w.curPage());var c = p.itemCount();var i = 0;var itemArray = new Array(c);for(i=0; i<c; i++){

itemArray[i] = p.item(i);}for( i = 0; i<itemArray.length; i++ ){

var item = itemArray[i];var width = item.width();var height = item.height();

switch(item.name()){

case "NMR Spectrum":var nmrSpc = new NMRSpectrum(item);nmr.processSpectrum(nmrSpc, procFile);nmrSpc.left = p.left + 10;nmrSpc.right = p.right - 60;nmrSpc.top = p.top+25;nmrSpc.bottom = p.bottom-8;

// Change the zoom range to 10 - 0:nmrSpc.horZoom(0.0, 10.0);

// Display title/solvent: Note if the title is empty, use the filename for the resulting files. var title2Use = nmrSpc.title;if( !title2Use) title2Use = "<No Title>";var tit = draw.text("<h4>" +title2Use+"/"+nmrSpc.solvent+"</h4>",true

);tit.left = p.left+30;tit.top = p.top+5;

// Display the parameters: var params = "<b>Title: </b>" + nmrSpc.getParam("Title");params += "<br/><b>Owner: </b>" + nmrSpc.getParam("Owner");params += "<br/><b>Solvent: </b>" + nmrSpc.getParam("Solvent");params += "<br/><b>Pulse Sequence: </b>" + nmrSpc.getParam(

"Pulse Sequence");params += "<br/><b>Acquisition Date: </b>" + nmrSpc.getParam(

"Acquisition Date");params += "<br/><b>Temperature: </b>" + nmrSpc.getParam(

Page 88: Scripting With Mnova 5.3.0

Mnova Scripting88

© 2009 MESTRELAB RESEARCH

"Temperature");params += "<br/><b>Number of Scans: </b>" + nmrSpc.getParam(

"Number of Scans");params += "<br/><b>Spectrometer Frequency: </b>" +

nmrSpc.getParam("Spectrometer Frequency");params += "<br/><b>Spectral Width: </b>" + nmrSpc.getParam(

"Spectral Width");params += "<br/><b>Lowest Frequency: </b>" + nmrSpc.getParam(

"Lowest Frequency");params += "<br/><b>Nucleus: </b>" + nmrSpc.getParam("Nucleus");params += "<br/><b>Acquired Size: </b>" + nmrSpc.getParam(

"Acquired Size");params += "<br/><b>Spectral Size: </b>" + nmrSpc.getParam(

"Spectral Size");

var par = draw.text("<font face=\"arial\", size=1>"+params+"</font>",true);

par.left = p.right - 60;par.top = p.top+30;

break;

case "Molecule":item.left = p.left + 15item.right = item.left + width;item.top = p.top+30;item.bottom = item.top + height;print(item.name());

break;case "Image":

item.left = p.right-width-10;item.right = item.left+width;item.top = p.top+6;item.bottom = item.top + height;print(item.name());

break;}

}w.update();

}

AP: This complex script (which includes the multiopen script) can be used to open, process (byapplying a processing template) a batch of 1D NMR spectra and then create two pages in the samedocument with different formats (changing the phase correction, zoom, cuttings, etc..) and saving theresulting pages as PDF, and .mnova files. The script will also generate a .log file with the processinghour and date.

Please make sure that you use the correct paths for the 'processing template' and also for the logo. Inthis case, both are saved directly in C:\.

Do not forget to visit our script repository at: http://www.mestrec.com/recursos.php?idc=11&i18n=1

//<GUI menuname="AP" tooltip="Auto Process and Save Multiple Spectra"/>/******************************************************************************************************Copyright (C) 2008 Mestrelab Research S.L. All rights reserved.This script is created for auto processing and saving multiple 1D NMR spectra into a desginated folder.

Page 89: Scripting With Mnova 5.3.0

89

© 2009 MESTRELAB RESEARCH

Authorized users of MNova Software may use this file freely, but this file is provided AS ISwith NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN,MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE.*****************************************************************************************************/function AP(){// Processing file. It must be created using the Full Processing dialog of MestReNova.// Change this to your actual path where this file is located.

const procFile = "C:/H1-Varian.mnp"; // Company Logo file. Change this to your actual file path:

const logoFile = "C:/MestreLab-logo.jpg";

// First allow the user to locate the folder where the NMR data are: var dirSettingsKey=new String("Multi Open/Last Directory");var dirName = settings.value(dirSettingsKey,Dir.home());dirName = FileDialog.getExistingDirectory(dirName, "Locate the folder where you raw data

are located:");// print("Directory: " + dirName);

settings.setValue(dirSettingsKey,dirName);

var dialog = new Dialog;dialog.title = "How to Locate NMR Data";

var leDirectory = new LineEdit;leDirectory.label = "Directory:";if (dirName)

leDirectory.text = dirName;dialog.add(leDirectory);

var leDirMask = new LineEdit;leDirMask.label = "Sub-Directory Mask:";leDirMask.text = "*";dialog.add(leDirMask);

var leFileMask = new LineEdit;leFileMask.label = "File Mask:";leFileMask.text = "fid"; dialog.add(leFileMask);

var recursiveSettingsKey=new String("Multi Open/Recursive");var cbRecursive = new CheckBox;cbRecursive.text = "Recursively"dialog.add(cbRecursive);cbRecursive.checked = settings.value(recursiveSettingsKey,false);

if(!dialog.exec()) return;

var pdfDirSettingsKey=new String("Multi Open/Last PDF Directory");var pdfDirName = settings.value(pdfDirSettingsKey,Dir.home());pdfDirName = FileDialog.getExistingDirectory(pdfDirName, "Locate the folder where the

results are to be saved:");// print("Directory: " + pdfDirName);

settings.setValue(pdfDirSettingsKey,pdfDirName);

Page 90: Scripting With Mnova 5.3.0

Mnova Scripting90

© 2009 MESTRELAB RESEARCH

// print("Directory: " + dirName);// print("Directory Mask: " + leDirMask.text);// print("File Mask: " + leFileMask.text);// print("PDF Directory: " + pdfDirName);

var dirName = leDirectory.text;var dir = new Dir(dirName);if (!dirName || !dir.exists){

MessageBox.critical("Directory " + dirName + " does not exist.", MessageBox.Ok);return;

}dir.cdUp();

var pdfDir = new Dir(pdfDirName);if (!pdfDirName || !pdfDir.exists){

MessageBox.critical("PDf Directory " + pdfDirName + " does not exist.",MessageBox.Ok);

return;}

settings.setValue(recursiveSettingsKey,cbRecursive.checked);var filesFound = getMaskFiles(dirName, dir.absPath, leFileMask.text, leDirMask.text,

cbRecursive.checked);// print("Files Found: " + filesFound);

// Now, process all the files one by one, and save them into .mnova and .pdf files: import_process_save_loop(filesFound, procFile, logoFile, dirName.length, pdfDirName);

}

// Open and process all spectra: function import_process_save_loop(files, procName, logoFile, dirNameLength, pdfDirName){// Open a log file:

var logFileName = pdfDirName+ "/log.txt";var f = new File(logFileName);f.open(File.WriteOnly);var s = TextStream(f);

// Add the starting date and time in the log file: var dt = new Date();s.write("Starting time:");s.write(dt);s.write("\r\n");

for(var i = 0; i < files.length; i++){

var dw = new DocumentWindow(Application.mainWindow.newWindow()); // Createnew document window

s.write(files[i]);s.write("\r\n");

// Ignore files starting with "scout":if( files[i].indexOf("scout") > -1){

s.write("\t-Ignored.\r\n");

Page 91: Scripting With Mnova 5.3.0

91

© 2009 MESTRELAB RESEARCH

}else{

// Generate a filename for the resulting PDF file: var fileName = Get_folder_name(files[i], dirNameLength, pdfDirName);

// Open and display the spectrum as the first page (full spectrum with parameters etc): if(!Open_Process_Spectrum(files[i], procName, 1)){

s.write("\t-Error opening and processing the file.\r\n");}else{

var ignore = ChangeLayout(logoFile, fileName, 1);if( ignore) {

s.write("\t-Skipped due to unexpected spectral type or errorchanging layout.\r\n");

}else{

// Open and display the spectrum again as the second page (auto cut, without parameters): if(!Open_Process_Spectrum(files[i], procName, 2)){

s.write("\t-Error opening and processing the file.\r\n");}else{

var ignore = ChangeLayout(logoFile, fileName, 2);if( ignore) {

s.write("\t-Skipped due to unexpectedspectral type or error changing layout.\r\n");

}// Save the two pages into one PDF and .mnova file (remove the '//' if you want other files be saved):

else{

serialization.save(fileName+".pdf", "pdf"); //Adobe PDF file format

s.write("\t-Generated "+fileName+".pdf\r\n");serialization.save(fileName+".mnova",

"mnova"); // MestReNova file format\\serialization.save(fileName+".txt", "ascii"); //

ASCII}

}}

}}dw.close(); // Close document window of processed spectrum

}

// Done. Close the log file. s.write("Completed time:");dt = new Date(); s.write(dt);

Page 92: Scripting With Mnova 5.3.0

Mnova Scripting92

© 2009 MESTRELAB RESEARCH

s.write("\r\n");

f.close();}

function Open_Process_Spectrum(specFileName, procName, flag){

if (serialization.open(specFileName)){

nmr.process(procName);var spec = new NMRSpectrum( nmr.activeSpectrum()); var proc=new NMRProcessing(spec.proc);

// Get the auto cut regions, and add to cut the solvent peak if flag = 2:if( flag==2){

var regs = spec.autoDetectNoiseRegions(); //this returns a list ofauto cut regions as SpectrumRegion object

regs.push(new SpectrumRegion(0.5,-0.5)); // remove refregs.push(new SpectrumRegion(2.60, 2.45)); // remove dmsoregs.push(new SpectrumRegion(3.45,3.25)); // remove waterregs.push(new SpectrumRegion(4.5,5.0)); // remove water

// print("New REGS"+regs);proc.setParameter("cuts.apply", true);proc.setParameter("cuts.list", regs); //now we apply the

cuts list to the process object}

// Re-apply the processing parameters:spec.proc = proc;spec.process();return 1;

}return 0;

}

function Get_folder_name(aFileName, dirNameLength, pdfDirName){

var result = new String;var found = -1;for(var i=aFileName.length-1; i >= 0; i--){

var c = aFileName[i];if( c == '\\' || c=='/'){

found=i;break;

}}var name = new String; for( var i=dirNameLength+1; i < found; i++){

var c= aFileName[i];if( c == '\\' || c == '/') {

name += ' ';c = '_'; // Changed by Len Chao

Page 93: Scripting With Mnova 5.3.0

93

© 2009 MESTRELAB RESEARCH

}name += c;

}result = pdfDirName + "/"+name;

return result;}

function Get_filename_from_path(pathName){

var result = new String;var found = -1;for(var i=pathName.length-1; i >= 0; i--){

var c = pathName[i];if( c == '\\' || c=='/'){

found=i;break;

}}for( var i=found+1; i < pathName.length; i++){

var c= pathName[i];result += c;

} return result;}

// Display spectrum and other objects (title, logo, and parameters etc) as desired. // Currently spectra other than 1D H-1 are ignored. You can change to do 1D C13 or 2D etc. function ChangeLayout(logoFile, fileName, flag){

var returnValue =0; // if returnValue=1 then ignore the spectrum.

// Load the logo file: serialization.open(logoFile);

// Now change the layout of the objects: var w = new DocumentWindow(Application.mainWindow.activeWindow());var p = new Page(w.curPage());var c = p.itemCount();var i = 0;var itemArray = new Array(c);for(i=0; i<c; i++){

itemArray[i] = p.item(i);}for( i = 0; i<itemArray.length; i++ ){

var item = itemArray[i];var width = item.width();var height = item.height();

switch(item.name()){

case "NMR Spectrum":var nmrSpc = new NMRSpectrum(item);

Page 94: Scripting With Mnova 5.3.0

Mnova Scripting94

© 2009 MESTRELAB RESEARCH

nmrSpc.left = p.left + 10;nmrSpc.right = p.right;if(flag == 1)

nmrSpc.right -= 60;nmrSpc.top = p.top+25;nmrSpc.bottom = p.bottom-8;

/ Change the zoom range to 10 - 0:nmrSpc.horZoom(0.0, 10.0);

// Display title/solvent: Note if the title is empty, use the filename for the resulting files. var title2Use = nmrSpc.title;if( !title2Use) title2Use = "<No Title>";var tit = draw.text("<h4>" +title2Use+"/"+nmrSpc.solvent+"</h4>",true

);tit.left = p.left+30;tit.top = p.top+5;

// Display the parameters: var params = "<b>Title: </b>" + nmrSpc.getParam("Title");params += "<br/><b>Owner: </b>" + nmrSpc.getParam("Owner");params += "<br/><b>Solvent: </b>" + nmrSpc.getParam("Solvent");params += "<br/><b>Pulse Sequence: </b>" + nmrSpc.getParam(

"Pulse Sequence");params += "<br/><b>Acquisition Date: </b>" + nmrSpc.getParam(

"Acquisition Date");params += "<br/><b>Temperature: </b>" + nmrSpc.getParam(

"Temperature");params += "<br/><b>Number of Scans: </b>" + nmrSpc.getParam(

"Number of Scans");params += "<br/><b>Spectrometer Frequency: </b>" +

nmrSpc.getParam("Spectrometer Frequency");params += "<br/><b>Spectral Width: </b>" + nmrSpc.getParam(

"Spectral Width");params += "<br/><b>Lowest Frequency: </b>" + nmrSpc.getParam(

"Lowest Frequency");params += "<br/><b>Nucleus: </b>" + nmrSpc.getParam("Nucleus");params += "<br/><b>Acquired Size: </b>" + nmrSpc.getParam(

"Acquired Size");params += "<br/><b>Spectral Size: </b>" + nmrSpc.getParam(

"Spectral Size");

var par = draw.text("<font face=\"arial\", size=1>"+params+"</font>",true);

par.left = p.right - 60;par.top = p.top+30;

break;

case "Molecule":item.left = p.left + 15item.right = item.left + width;item.top = p.top+30;item.bottom = item.top + height;print(item.name());

break;case "Image":

Page 95: Scripting With Mnova 5.3.0

95

© 2009 MESTRELAB RESEARCH

item.left = p.right-width-10;item.right = item.left+width;item.top = p.top+6;item.bottom = item.top + height;print(item.name());

break;}

}w.update();return returnValue;

}

Page 96: Scripting With Mnova 5.3.0

Thank you!

‘Thank you for reading this Manual, and for purchasing this release version ofMNova. We will be very keen to read your feedback on the application, to hearabout any bugs you may find and to also listen to any additional ideas orsuggestions you may have.

Please remember that you can send all those, and any queries about thesoftware, or requests for help, to:

[email protected]

Keep checking our web site (www.mestrelab.com) for additional information onour range of software packages, and for news on our company.’