OPUS Programming
OPUS Programming
I 24313
Version 4
PROGRAMMING
Table of Contents
Introduction
1
2.2
2.3
2.4
2.5
Macros
5
5.5
iii
5.6
5.7
5.8
5.5.6
Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Compiling Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Macro Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.1
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.1.1 Variable Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.1.2 Combobox Variables . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.1.3 Selecting Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.2
Differences in File Handling . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.3
System Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.4
Function Parameters and Parameter Assignment . . . . . . . . . . . .
5.7.5
Time-behavior of Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.6
Print Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.7
Calculations with Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.8
Jump Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.9
Start Loop with For Each Option . . . . . . . . . . . . . . . . . . . . . . . .
5.7.10 Load Multiple Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.11 User Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.12 Client/Server Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.13 Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Writing Portable Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5-13
5-13
5-13
5-16
5-16
5-17
5-17
5-17
5-18
5-18
5-19
5-19
5-19
5-19
5-20
5-20
5-20
5-20
5-21
5-21
6.2
6.3
6.4
6.5
6.6
6.7
6.8
6.9
6.10
6.11
6.12
6.13
6.14
6.15
6.16
6.17
6.18
6.19
6.20
6.21
iv
6.22
6.23
6.24
6.25
6.26
6.27
6.28
6.29
6.30
6.31
6.32
6.33
6-50
6-53
6-54
6-60
6-61
6-64
6-65
6-67
6-68
6-71
6-75
6-77
External Programs
7
7.2
8.2
VisualBasic Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.1
Generating Forms and Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.2
Objects and Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.3
OPUS Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.4
Performing Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.5
Accessing Spreadsheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.6
Repeated Calls Using a Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.7
Accessing Spectral Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8-1
8-1
8-2
8-4
8-4
8-5
8-6
8-7
8-9
9.2
9.3
9.4
9.5
9.6
9.7
9.8
9.9
9.10
9.11
9.1.1
Variable Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
9.1.2
Variable Declaration for STRING, NUMERIC and BOOL . . . . . 9-2
9.1.3
Variable Declaration for FILE . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
9.1.4
Variable Declaration for BUTTON . . . . . . . . . . . . . . . . . . . . . . . 9-4
9.1.5
Marking a Variable for Update . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-4
9.1.6
Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5
PROGRAM Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
9.2.1
General Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
9.2.2
Command Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
9.2.3
Command Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6
PARAMETER Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7
Macro Functions Sorted Alphabetically . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-8
Functions Sorted by Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10
System Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12
9.6.1
GetOpusPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12
9.6.2
GetUserPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-12
9.6.3
GetMacroPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
9.6.4
GetVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
9.6.5
GetArrayCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13
9.6.6
GetLength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
9.6.7
FindString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-14
9.6.8
CallMacro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15
9.6.9
SaveVars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-15
Flow Control Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-16
9.7.1
StartLoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-16
9.7.2
EndLoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-17
9.7.3
Goto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-17
9.7.4
Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-17
9.7.5
If ... Else ... Endif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-18
User Interface Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-20
9.8.1
Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-20
9.8.2
StaticMessage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-21
9.8.3
UserDialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-21
Input Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-22
9.9.1
Enter Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-23
9.9.2
GetParameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-24
9.9.3
FromReportHeader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-24
9.9.4
FromReportMatrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-25
9.9.5
ReadTextFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-25
9.9.6
GetEnumList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-25
Output Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-26
9.10.1 TextToFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-26
9.10.2 PrintToFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-27
File Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-27
9.11.1 LoadFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-28
9.11.2 ScanPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-29
9.11.3 Copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-29
9.11.4 Rename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-30
9.11.5 Delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-30
vi
9.12
9.13
9-30
9-30
9-31
9-31
9-32
9-32
9-32
9-33
9-33
9-33
9-33
10.8
vii
10.9
10.10
10.11
10.12
11
10-21
10-21
10-21
10-21
10-21
10-22
10-23
10-23
10-23
10-23
10-24
10-24
10-24
10-25
10-25
10-25
10-27
10-27
10-29
10-29
10-30
10-31
10-33
10-33
10-34
10-35
10-36
12-1
12-1
12-2
12-2
12-3
12-3
12-4
12-5
12-5
12-6
12-7
12-8
12-9
12-9
viii
12.4
12.5
ix
12.5.29
12.5.30
12.5.31
12.5.32
12.5.33
12.5.34
12.5.35
12.5.36
12.5.37
12.5.38
12.5.39
12.5.40
12.5.41
12.5.42
12.5.43
12.5.44
12.5.45
12.5.46
12.5.47
12.5.48
12.5.49
12.5.50
12.5.51
12.5.52
12.5.53
CLOSE_OPUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TAKE_REFERENCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MEASURE_SAMPLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
COMMAND_LINE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
STOP_THREAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ACTIVATE_DIALOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LOAD_EXPERIMENT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GET_USERRIGHTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PACKET_AVAILABLE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GET_CLIENTAREA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ACTIVATE_DISPLAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GET_LIMITS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SET_LIMITS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DISPLAY_BLOCK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UNDISPLAY_BLOCK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ENUM_STRINGS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GET_VERSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ASK_THREAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FIND_FUNCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
WORKBOOK_MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
GET_SELECTED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
LIST_BLOCKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SHOW_TOOLBAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
HIDE_TOOLBAR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
QUICK_PRINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12-41
12-41
12-42
12-43
12-43
12-44
12-44
12-45
12-45
12-46
12-46
12-47
12-47
12-48
12-49
12-49
12-50
12-50
12-51
12-52
12-52
12-53
12-53
12-54
12-55
Scripts
13
13.3
13.4
13.5
13.5.4
13.5.5
13.5.6
13.5.7
13.5.8
13.5.9
13.5.10
13.5.11
13.5.12
13.5.13
13.5.14
13.5.15
13.5.16
Frame Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Image Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Label Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ListBox Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Multipage Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
OptionButton Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ScrollBar Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SpinButton Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TabStrip Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TextBox Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ToggleButton Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Timer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Debugging Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13-28
13-29
13-29
13-29
13-29
13-30
13-30
13-30
13-31
13-31
13-31
13-32
13-32
xi
Programming, Controlling
and Communication with
OPUS-NT
Data acquisition and processing under OPUS-NT can be automated using selfwritten programs. These programs can either be written in OPUS own macro
programming language, or in Microsofts VBScript. OPUS-NT provides an
interface to third party programs, giving you a link to software designed for purposes other than spectral data acquisition and manipulation. In addition, you
can use this interface to access programs you have written yourself.
The first part of this manual covers the interfaces for external programs. The
second part references the OPUS functions, macro commands, client/server and
VBScript commands.
1.1
OPUS provides several ways to control program routines. These range from the
simple recording of routine commands in a macro to sophisticated evalutaion
algorithms, which need OPUS parameters and specral data. And, for example,
third party software to control accessories.
This is established by the use of:
Macros
VBScript
external programs
1.2
Interfaces
OPUS comprises of several interfaces for data exchange with other software.
Supported are:
OPUS-NT Programming
11
12
OPUS-NT Programming
External Programs
External Programs
External programs are employed whenever you encounter tasks that cannot be
handled by OPUS-NT, or if dedicated programs to solve these tasks already
exist.
Basically, there are two categories of external software:
Programs designed by the user to perform specific calculations or
data manipulations, and which are able to communicate with OPUS.
Any other third-party program, which can be launched and controlled
by OPUS.
However, the external software must be written to run on the Windows NT platform, because upon the launch of the program, system functions will be called
directly. Therefore, the program must either be a Win32 executable file, a 16
bit Windows, or a DOS program (an OS/2 program without graphical output
will also work), This requires, that the respective subsystem has been installed
on your computer. In addition, batch files can be used. These files can be identified by their extensions:
1) .exe
2) .com
3) .bat
Currently, the following OPUS commands are supported by the interface:
Reading and writing spectral data from/to OPUS spectrum files and
3D files, where the frequency range can be selected.
Loading and unloading OPUS files.
Running macros and VBScripts, including parameter exchange.
Access to information of selected files and the possibility to expand
OPUS by new functions.
Reading and writing OPUS parameters from/to OPUS spectrum files.
Reading data from report blocks.
Generating and positioning windows.
OPUS-NT Programming
21
2.1.1
Programs are launched from within OPUS by the External Program command,
located in the File menu.
Upon selecting the command, a dialog box opens. Use this dialog box to specify the name and location of the external program, and any additional parameter
or OPUS files you would like to transfer to the program. To launch the program
click the Execute button.
22
OPUS-NT Programming
External Programs
2.1.2
On this page you specify the program you want to start and any additional
parameters. You can either:
use the Browse button to locate the program and select it by doubleclicking, or
open the drop-down list to choose a program you ran before, or
manually type in the programs name.
The external program will be started after clicking the Execute button. If you
dont specify a path OPUS will first look in the OPUS directory, next in the
active directory (the directory that was used at last), followed by the Windows
system directory (SYSTEM/SYSTEM32) and any directory indicated by the
path environment variable.
In the following, the parameters of the dialog page will be explained in detail:
Communication
Specifies the type of data communication between OPUS and the external software:
Dynamic Data Exchange OPUS acts as a client for the external program, which in turn must function as a server. Choose this communication type also if no data exchange will take place.
Named Pipe is restricted to programs which were especially
designed to function as a client to OPUS. A Named Pipe communi-
OPUS-NT Programming
23
cation ensure fast data transfer between OPUS and the external program, in combination with the possibility of controlling OPUS by
commands.
24
OPUS-NT Programming
External Programs
2.1.3
OPUS-NT Programming
25
2.1.4
The DDE Command Page comprises all DDE interface settings to call a server
program.
Poke
This option sends binary data to the server via the XTYP_POKE transaction.
26
OPUS-NT Programming
External Programs
Execute
A server command will be executed via the XTYP_EXECUTE transaction.
The external program does not return any data.
Request
A server command will be executed via the XTYP_REQUEST transaction. The
external program returns the result.
Server Name
Defines the name of the server, which was used by the server to register with the
system.
Topic
Defines the class of the command. The topic depends on the external program
and the command to be executed; consult the documentation of the program
used.
Item
Specifies the command which will be executed. The value depends on the program and the performed command; consult the documentation of the program
used.
Data
This list is only of importance, if Poke was chosen as DDE transaction type.
Enter the binary data, which will be forwarded to the server. All data has to be
coded in string format, for example 65 0x0A 0x0D. If the data is a character
string, it is to be enclosed in hyphens: hallo. In this case, the respective
ASCII codes including a terminating 0 will be entered in the list. A prefix (i =
int, l = long, d = double, f = float) is used to classify the following data to be of
the given numerical type. z in combination with a figure n is used to add n
zeros.
2.1.5
Writing software
You can write your own client software to communicate with OPUS. These
programs can be used to assign tasks to OPUS and read data from OPUS.
Named Pipes, which are generated on the host computer can be used to handle
the communication between your program and OPUS. Named Pipes can easily
be accessed through several programming languages e.g. the language C. In C,
these pipes are addressed by commands similar to the commands used for files
access, fopen and fclose. In addition, Named Pipes are supported by
many network platforms.
Bruker Optik GmbH
OPUS-NT Programming
27
OPUS also provides a DDE server service, that allows the external program to
trigger an OPUS function with a DDE command.
To create your program, you can make use of various developing environments.
The only restriction that applies is that the resulting executable must run on the
Windows NT platform.
2.2
Macros
OPUS offers its own macro system, consisting of an editor, a debugger and a
converter to translate macros written with OPUS-OS/2.
Macros are intended to be used, if a command sequence has to be processed
repeatedly. Combining these commands in a macro saves the user the trouble of
manually calling these commands (and specifying their parameters). Furthermore, frequently used macros can be integrated as command buttons into the
OPUS tool bar.
Macros are text files that can be created using any kind of ASCII text editor.
However, OPUS provides a comfortable Macro Editor for this purpose. In
combination with the OPUS Macro Debugger, macro programming and testing
becomes straight forward.
2.3
VBScripts
2.3.1
Accessing Scripts
28
OPUS-NT Programming
VBScripts
2.3.2
Script
Enter the name (including the path) of the script to be launched. The drop-down
list holds the names of the scripts which were started during an earlier session.
Alternatively, use the Browse button to open a Load File dialog and locate the
script.
Hidden
The script will run in the background instead of being displayed.
OPUS-NT Programming
29
Parameters
Additional parameters to be used in combination with the script can be specified
in this field. These will be exchanged in string format. This causes an OpusInform event in the script, with the string as a parameter.
2.3.3
Generating a Script
Choose the New button in the File menu and VB Script in the displayed dialog
box to generate a new script. This will automatically open the Form Editor window.
Use the Form Editor and the Toolbox to include dialog boxes and controls in the
script. Select a tool and draw a rectangle to position a new control. The tool bar
in the lower part of the window controls the position of the control buttons
within the script. Start the script by clicking on the
text input window by clicking on the
about using the Scripting Editor.
210
OPUS-NT Programming
2.4
You can include your scripts and macros in a tool bar to comfortably access the
most frequently used programs. OPUS must recognize the macro/script (and
the correlated bitmap) upon starting. Therefore, for each macro/script you have
to add an entry in the USERMAC.LST file, stored in the OPUS directory.
Path\File@Menunumber@Itemname@Tooltiptext@Statusline
Path\File
Menunumber
Itemname
Tooltiptext
Statusline
The text which will be displayed in the status line while the
macro/script is running.
OPUS-NT Programming
211
The numbers of the menus can be taken from the following table:
Menu
Menu Number
Measure
Manipulate
Evaluate
Display
Macro
Edit
Validation
Setup
File
10
In order for the macro/script to be represented by an icon on the tool bar, you
have to provide a 16 color bitmap of 16x15 pixels of this icon. This bitmap has
to be stored as <Macro/Scriptname>.bmp in the same path as the corresponding
macro/script.
Example:
C:\OPUS-NT\KALIBRATION.MTX@1@Measure@Standardcalibration
@Macro running
This entry includes the macro CALIBRATION.MTX in the Measure menu. Standard calibration will be displayed as tooltip. The icon bitmap must be stored as
CALIBRATION.BMP in the C:\OPUS-NT\ directory.
2.5
Auto-starting a Script
In some cases it is desired to automatically perform certain tasks upon launching OPUS. In this way, a specifically configured OPUS user interface could be
automatically presented to the user. To automatically process a script after the
start of OPUS, a parameter has to be included in the Windows NT command
line:
Opus.exe /SCRIPT=start.obs
This command automatically loads and processes the script start.obs after
starting OPUS. The same command can be included in a Windows NT shortcut
for OPUS (refer to your Windows NT documentation).
212
OPUS-NT Programming
Syntax:
<Function> ([File],{Parameter})
at the command line, the file ABBOE05.0 will be baseline corrected. If the file
has not been loaded in OPUS, it will load automatically prior to the baseline
correction.
The file which is to be processed has to be enclosed by hyphens. The empty
braces at the end of the command symbolize, that no parameters have been
specified. In that case, the default values will be used. However, parameters
can be entered in order to make the command more specific. Parameters consist
of a three character code, followed by an equal sign and a value (e.g. BME=1).
Parameters have to be separated by a comma.
A file can be loaded more than once at the same time; therefore, a number is
added after the file name to identify the version of the file. This number is
called clonecount. Furthermore, a data file usually consists of several data
blocks, which can be addressed separately:
Baseline ["e:\opus\data\abboe05.0" 3:AB]
This command processes the absorption data block of the third version (copy)
of the file ABBOE05.0.
OPUS-NT Programming
31
32
OPUS-NT Programming
Controlling External
Programs
You can also make use of an OPUS interface to control third party software.
This allows you for example to control additional laboratory equipment, that
you would like to use in combination with your spectrometer.
OPUS-NT Programming
41
42
OPUS-NT Programming
Creating Macros
5.1
Creating Macros
5.2
A few syntax rules apply for all elements of the macro language:
A macro line (command, declaration) must always be terminated by
a semicolon.
A macro line can be split into several text lines within the text file.
The three section keywords (VARIABLES SECTION, PROGRAM
SECTION, PARAMETER SECTION) must be present in each
macro, even if a section is empty.
The section keywords do not need a semicolon.
Variable names are always enclosed by < > (e.g. <Index>).
Strings within a macro line must be enclosed by single quotes (This
is a string).
All command lines need brackets after the command name, even if
they do not need command arguments.
A line beginning with the keyword REM will be ignored.
The most common errors in programming macros are missing section keywords
and semicolons.
OPUS-NT Programming
51
5.3
Any line in the three macro sections can be disabled during a macro run by typing REM at the very beginning of a line. This either can be used to temporarily
disable lines for testing instead of erasing them, or for adding comment lines
within the macro for better readability.
When converting OPUS-OS/2 macros commands which are currently not available will automatically be preceded by the REM keyword.
5.4
5.4.1
General
52
OPUS-NT Programming
or
down the text body, in order to simplify restructuring the program. Variables displayed in the lower window cannot be repositioned, but are listed chronologically to their creation.
You can search for any string in the macro command and the variables section.
Enter the string you want to search for in the entry field below the two search
buttons. Start the search by either clicking on the Search Command or Search
Variable button. Click the button repeatedly to find the next occurance of the
search string. After searching the macro is completed the search starts again at
the top.
OPUS-NT Programming
53
5.4.2
Special Commands
Drop-down lists provide variables or key words for all fields, depending on the
type of the parameter. Each field must contain a value for the command to
function properly. The syntax is described in chapter 9. Use the Add Variable
button (see the next chapter) to define a new variable.
The commands listed in the following open their own dialog box:
CallMacro
UserDialog
StaticMessage
54
OPUS-NT Programming
Figure 11: User Dialog Setup and Static Message Dialog Box
The command Enter Expression is an exception in that sense, that instead of the
command name an equal = sign will be used.
OPUS-NT Programming
55
5.4.3
56
OPUS-NT Programming
If you select FILE as variable type you can specify, besides the name, one or
more data blocks in the fields that appear. Choose the desired block type from
the three drop-down list and press the Add button; they will appear in the list in
the lower part of the window.
The first list contains a complete list of spectrum data blocks. The second list
consists of derivative blocks, and the last list comprises the rest of the extended
blocks. Blocks that are marked by a slash / are linked to spectral data. Some
blocks can either be linked or not, like for example the Search data block; while
the report of a spectrum search is linked to the spectral data block (AB/Search),
the report of an information search is not.
5.4.4
OPUS commands are inserted by simply selecting the desired OPUS function
from the pull-down menu or the tool bar while you edit a macro. This causes
the program code to be inserted below the selected line or to be appended to the
macro if no line is selected. You can reposition the code within the program
with the up and down buttons. OPUS commands can be edited in the same way
as any other macro command. Double-click on the code line and press the
button. The dialog box of the OPUS command will open and you can alter your
settings.
When you select a command its dialog box will be displayed as usual, allowing
you to set the function parameters. The list of files to be processed is replaced
by a drop-down list comprising all file variables. Instead of a file name you
select a variable. This requires that the variable you want to use must be
defined beforehand.
OPUS-NT Programming
57
After clicking the command button to execute the command a dialog appears,
listing all necessary parameters with their names and current values. In the last
column choose a macro variable for any parameter from the list. The parameters will be assigned to these variables during runtime of the macro.
The checkbox at the beginning of each row determines, whether the parameter
will be entered into the program line (box checked) or the parameter section.
Parameters which are assigned variables must be included in the program
line.
Some OPUS functions are able to return results to the macro. For example a
data acquisition generates a file that must be accessed by the macro. In this case
the macro editor automatically generates a new FILE variable named
<$ResultFile, x>, where x will be incremented automatically.
Example
<$ResultFile 1> = MeasureSample (0,{...
If OPUS functions return text instead (e.g. SendCommand), an additional selection list will be displayed above the parameter list of the parameter dialog.
Choose a (already defined) variable from this list.
Example
<Result> = SendCommand (0,{...
5.4.5
OPUS command lines are edited similar to macro command lines. First select
the line by double-clicking it. Clicking on the
button causes the dialog box
of the function to open; the current parameters will be displayed. After clicking
on the execution button of the function, the dialog box for parameter selection
will appear.
58
OPUS-NT Programming
Debugging Macros
5.5
Debugging Macros
Also you can search a text string within a macro or on the variable page. Enter
the string you want to search in the entry field left from the Search button. Start
the search by clicking on Search. The line containing the string will be
selected. If you click on Search repeatedly the following occurrence of the
string is found, until the macro has been completely scanned. After that, the
search will begin again at the top of the macro. The line number in which the
OPUS-NT Programming
59
Arrays are marked by a plus sign in the Variables window; the value of an array
is the one chosen for example from a selection of a pop-up menu. Double-clicking expands the array, that is every value of the array will be displayed. The
index of each value is displayed in the Name column.
510
OPUS-NT Programming
Debugging Macros
5.5.1
The first line of the program is marked by a little green arrow to indicate the
next line to be executed. This line can be executed by clicking the Single Step
button. The arrow moves to the next command to be executed (not necessarily
the next program line) and stops. As long as a command is being executed you
cannot access the window. If the values of variables were changed by a macro
command line, they will be displayed with their new values.
Variable values can be changed at run time in the debugger. Select the line containing the value to be changed. Enter the new value in the entry field next to
the Change Value button and click on the button. For numeric variables only
numbers are allowed. For BOOL variables either a number (0 or 1) or TRUE
and FALSE are accepted.
5.5.2
If the debugger encounters a sub routine call (Call Macro....) while stepping
through a macro, you have the choice between two options:
If you continue in Single Step mode the sub routine will be processed at once,
i.e. the debugger evaluates the routine without explicitly stepping through it.
The cursor stops at the next line of the main program. You should use this
method only, if you are sure that the sub routine contains no errors.
Bruker Optik GmbH
OPUS-NT Programming
511
On Step into Submacro an additional debugger window opens and the sub routine will be executed step-by-step. After the sub routine is completed its window will be closed automatically, and the execution of the main program
continues. Use this mode if the sub routine is likely to contain errors.
5.5.3
Double-clicking on a line number in the debugger window will set a stop mark,
indicated by a small icon at the beginning of the line. Remove the mark by doubleclicking on it. A stop mark causes the debugger to halt at this program line,
if Run to Breakpoint is used for the execution. This is especially helpful while
debugging large macros, in case you are certain that the program code executed
before the marked line is free of errors. Run to Breakpoint takes you directly to
the line you have marked. Be sure that no branch occurs which causes the program to bypass the stop mark. In this case, or if no stop mark has been inserted,
the macro will be executed completely without a stop.
5.5.4
Aborting a Macro
The Single Step mode can be aborted with the Abort Macro button. This command is not active, while the debugger is busy evaluating a command.
Breakpoints which are set during debugging can be stored in the macro text file
with the Store Breakpoints button (see Figure 17). Whenever the macro is
started in a debugger session these breakpoints will be activated automatically.
When sub macros are called in a debug session, the debugger will automatically
stop at the predefined breakpoints in the sub macro.
The breakpoints are stored in a new section starting with the keyword
BREAKPOINTS (and followed by the line numbers of the breakpoints)
which is appended to the macro. Please note that each line numbers requires a
separate line and has to be terminated by a semicolon.
Example
BREAKPOINTS
3;
512
OPUS-NT Programming
Compiling Macros
12;
38;
5.5.5
Automatic Stop
5.5.6
Error Messages
While a macro runs only fatal error messages are displayed while other errors
have to be handled with If (MACROERROR, .EQ., TRUE); constructs.
When a macro is run in debug mode, all error messages will be shown to facilitate debugging and help locating critical sections in a macro.
5.6
Compiling Macros
Macros are generally written and stored as text files. During execution the
macro text file is interpreted i.e. the text format is converted (compiled) into a
binary format which can then be executed. The Compile function performs this
step separately and generates a macro file with a binary format which can be
executed directly.
Reasons to use compiled binary macros:
a larger binary macro starts faster
a binary macro cannot be modified by an unauthorized user
Please note that binary macros cannot be changed directly. If modifications are
necessary you need to modify the original text based macro and compile it
again. Compiled macros will also not run in the macro debugger.
To prevent permanent changes of macros using the CallMacro or RunMacro
functions you need no longer specify the file extension for the sub-macro. If no
extension is specified the system automatically uses the file type which is
present. If both types are found the system will use the text version.
5.7
Macro Converter
Use the Macro Converter to translate macros written under OPUS-OS/2 into the
OPUS-NT format. The conversion may require some changes as a result of the
different macro syntax.
OPUS-NT Programming
513
OS/2 macros all have the file extension .MAC, OPUS-NT macros the extension .MTX. The Macro Converter generates a text file with name of the OS/2
macro and the extension .MTX as well as a log file with name of the OS/2
macro and the extension .LOG.
The Macro Converter was designed as an assistant, who guides you through the
necessary steps. Calling up the Converter first displays some general information about the use of the program. On the second page, you specify the name of
the OS/2 macro to be processed, either by typing it or use the Change Macro
function to browse the directory. You can only switch to the next page, if you
entered a valid macro name.
The next page contains the settings for the destination directory, and the name
of the resulting OPUS-NT macro. The destination directory is by default the
same as the one containing the OS/2 macro. The default directory and macro
name can be changed either manually, or by navigating to another directory
using the Change Output File button. Start the conversion by clicking on Finish.
514
OPUS-NT Programming
Macro Converter
Log Files
During the conversion of an OS/2 macro a log file will be generated containing
You should check the log file before you attempt to run the converted macro.
System Variables
If the OS/2 macro contains system variables (e.g. directories), code will be
added during the macro conversion, that ensures the correct initialization of
these variables. Information about which lines have been changed are available
in the log file.
Example
STRING <$OPUS-Path>; (system variable of the main OPUS directory)
Example
STRING <$Data File Path>(system variable of the OPUS data directory)
OPUS-NT Programming
515
Measurement Commands
Only those parameters will be added in the command line of the Macro Editor,
which were assigned variables. All other parameters are included in the
PARAMETER SECTION. If the parameters XPP (experiment path) and EXP
(experiment name) are not assigned, a warning will be included in the log file.
Obsolete Parameters
Parameters that are obsolete in OPUS-NT will be handled like commands that
are not implemented i.e. a REM command will precede the parameter and render it inactive.
5.7.1
Variables
The types of variables and their handling in OPUS-NT differ from their use in
OS/2.
516
OPUS-OS/2
OPUS-NT
NUMERIC
NUMERIC
STRING
STRING
CHECKBOX
BOOL
COMBOBOX
STRING (Array)
BUTTON
BUTTON
FILE
FILE
LABEL
no variable
OPUS-NT Programming
Macro Converter
After the macro has been started once, the declaration line will change to:
*STRING <Text> = New Text;
5.7.2
OPUS-NT Programming
517
chosen. The following examples illustrate this using the Baseline Correction
command.
Example Overwrite Files
VARIABLES SECTION
FILE <File> = AB;
PROGRAM SECTION
Baseline([<File>:AB] , {BME=1, BCO=0, BPO=64});
Note that the modified file is not saved by the macro. If you want to save the
result, you need to include the Save command or save the file manually.
Example Create new files
VARIABLES SECTION
FILE <F1> = AB;
FILE <@result401>;
PROGRAM SECTION
Baseline([<F1>:AB] , {BME=1, BCO=0, BPO=64});
SaveAs([<F1>:AB], {OEX=1, COF=2, SAN=WORK.301,
DAP=E:\opus\WORK});
Restore ([<F1>:AB],{});
<@result401> = LoadFile (E:\opus\WORK\WORK.301, WARNING | ABORT);
If the Create new files option was chosen, the converter expands the OPUS-OS/
2 command automatically to guaranty compatibility.
line 1:
line 2:
line 3:
line 4:
5.7.3
System Directories
The system path variables of OPUS-OS/2 are no longer supported. These variables will be initialized by the appropriate command lines.
5.7.4
518
OPUS-NT Programming
Macro Converter
Variables for parameter values that were used in OPUS-OS/2 in the form of an
assignment, are now included directly in the parameter list of the command
(e.g. ..., DAP = <data path>, ...). They will be replaced by their current value
prior to the execution of the command.
5.7.5
Time-behavior of Macros
OPUS-OS/2 macros are executed asynchronous, i.e. commands are sent to the
OPUS task manager, who then decides when to execute the commands. Only a
few functions (e.g. dialog boxes, wait function) were able to pause a macro
until all commands forwarded to the task manager were processed. In some
cases a necessary synchronization of the macro had to be achieved by including
wait functions with the wait time set to 0.
OPUS-NT macros are executed synchronous, i.e. the next command will only
be executed after the termination of the currently processed command. This
makes the use of wait functions as described above obsolete. These commands
are removed upon macro conversion.
5.7.6
Print Functions
Currently, the Print function has not been implemented. OPUS-OS/2 print
commands will be converted to PrintToFile function. Make sure, that the output directory and file name was set properly.
5.7.7
So far, calculations that contained only variables (and no spectral data) had to
be performed with the spectrum calculator. OPUS-NT supports the direct use
of mathematical expressions. For example
<Number> = <Number> + 1;
5.7.8
Jump Instructions
OPUS-OS/2 jump instructions are replaced by Goto (Label) statements. Conditional Jumps are expanded to three lines:
OS/2 Macro:Jump to Label if Expression;
NT Macro:If (Expression);
Goto Label;
Endif;
Please note, that jump statements from OPUS-OS/2 macros can be simplified
by using the new If ... Else ... Endif structure. However, this is not done automatically; in case of macros containing several conditional jumps we recom-
OPUS-NT Programming
519
mend to manually replace the If ... Endif structures by If ... Else ... Endif
structures.
5.7.9
The Start Loop instruction in combination with the option For each File is
now identical to all other StartLoop instruction. Instead of the counter or a
NUMERIC variable, just state the FILE variable as a counter.
Example:
FILE <File> = AB;
.....
StartLoop ([<File>], 0);loop count = number of files selected
5.7.10
The Load function with the Load multiple option is replaced by the general
LoadFile macro function, followed by a StartLoop instruction, with the
FILE variable specified for the loop count.
Example:
<File> = LoadFile (D:\OPUS\DATA\*.0, WARNING | ABORT);
StartLoop([<File>], 0);
.....
EndLoop(0);
5.7.11
User Dialogs
The variable <Text> can be used for an Edit control as well as for comment
lines or a combo box.
EDIT:<Text>
TEXT:<Text>
COMBOBOX:<Text>shows a Combobox.
5.7.12
Client/Server Calls
520
OPUS-NT Programming
5.7.13
Conversion Functions
Conversion functions (like JCAMP, data point table) no longer exist in OPUSNT. Non-OPUS files are converted automatically upon loading the file, if
OPUS recognizes the file format. The converted file will then be saved in a different format, if the appropriate switches are set when using the SaveFile command. When converting OPUS-OS/2 macros these changes have to be done
manually.
5.8
A portable macro allows to copy and run a macro written on a specific system
on any other system. This will be straightforward if both systems have an identical directory structure which is expected by the macro.
In general, there are several ways to write such macros:
1) All drive and path specifications are stored in variables, which then can
be set via a user dialog. If these variables are marked for update, they
must only be set during the initial run of the macro. If only a few paths
are included in the macro, this may be acceptable, but with an increasing
number of paths involved it can become tedious work.
2) A much better and preferable solution is to use a variable home directory
with a fixed subdirectory structure. Not only the single variable, which
has to be set, but also the transparency of this macro to the user is guar-
OPUS-NT Programming
521
anteed, because results are located in the same subdirectories on all systems.
3) The best solution uses either the OPUS path or a User path as home
directory, with a fixed sub directory structure. In this case, the first command line in a macro must be <Path> = GetOpusPath (); or <Path> =
GetUserPath (); which sets the variable to the current path. There is no
need to set the path manually.
During the installation of OPUS-NT, some sub directories are already created.
These directories are accessible by all users. If access to some of the sub directories should be restricted, it is still recommended to maintain the OPUS sub
directory structure.
OPUS
DATA
MEAS
XPM
METHODS
MACRO
SEARCH
PRINTS
SCRIPTS
522
the main path for the OPUS program and all files necessary to
run OPUS.
sample data.
measured spectra .
experiment files.
method files for integration, QUANT, IDENT etc.
macros.
intermediate search reports and method files.
output from printing into a file.
plot layout scripts.
OPUS-NT Programming
General Remarks
6.1
6.1.1
General Remarks
Syntax
6.1.2
A macro has to fulfill various tasks, like data handling and data processing, or
making decisions depending on the outcome of an OPUS report. These tasks
can only be performed effectively, if the macro operates with variables instead
of constants like file names, dates etc. Therefore, the OPUS macro systems
offers several types of variables.
Bruker Optik GmbH
OPUS-NT Programming
61
If a numerical value should be changed during run time of the macro, a variable
of the type NUMERIC has to be employed. For file names on the other hand,
which can be supplied by the user during run time, a variable of type TEXT is to
be used.
6.1.3
Variable Names
A variable is identified by its unique name. The name will be displayed in dialog boxes, and should therefore express the purpose of the variable. For example, the use of the name x start frequency provides more information that just
the name x.
6.1.4
Variable Types
Several types of variables are available in the OPUS-NT macro language. They
are summarized in the following; details about the syntax are given in chapter 9
Text Variables
Text variables are used to save text, like file names or results.
Values can either be entered through dialog boxes, using statements or read
from parameters or reports.
Numerical Variables
Numerical variables are used to save numbers.
Values can either be entered through dialog boxes, using statements or read
from parameters or reports.
Boolean Variables
Boolean variables are used to save the values TRUE or FALSE.
Values can either be entered through dialog boxes, using statements or read
from parameters or reports.
File Variables
File variables are used to save spectra.
Spectra that have already been loaded into the OPUS Browser are assigned to
the variable using a dialog box. Spectra that were generated by a macro are
assigned via statements.
62
OPUS-NT Programming
Command Buttons
Command buttons are used to control the flow of a macro.
Command buttons cannot be changed during run time, and therefore are not
variables in the true sense. However, they are declared in the variable section,
and are always linked to a Goto instruction condition.
Except command buttons all variables can also be used as arrays, i.e. they can
hold more than one value. The different values are addressed using index numbers.
6.1.5
Text and numerical variables (and boolean variables under certain conditions)
can be converted into each other. Detail are given in the Macro Reference section.
6.2
Task
Acquire a spectrum using a macro.
Macro Functions
This example uses no special macro functions.
OPUS Functions
Measurement
The measurement command has a special status compared to normal OPUS
functions; data acquisition requires a multitude of parameters, some of which
are linked to each other. Before you use the measurement command in a macro,
you need to define an experiment file, which you will use in combination with
the macro. For the use with this example macro, you must generate an experiment file DEFAULT.XPM, which we save in the directory
C:\OPUS_NT\XPM. The type of data acquisition should be set to absorption
spectrum.
OPUS-NT Programming
63
The first column list the Parameter abbreviations that are used by OPUS.
In addition, a check box controls, whether the parameter will be entered
in the command line or the parameter section. While for all other OPUS
commands these check boxes are selected by default, this is not the case
for the Measurement command. Only Experiment and Experiment
Path are checked.
In the second column, the parameter name is displayed followed by the
current value of the parameter listed in the third column. The values for
Experiment and Experiment Path are the ones you entered in the
Measurement dialog box.
The last column is reserved for macro variables. In our case all table
cells in this column are empty.
6) Click on OK. The following line will appear:
<$ResultFile 1> = MeasureSample (0, {EXP=it.xpm, XPP=C:\OPUS_NT\XPM});
OPUS-NT Programming
(QTCNN1275EQOOCPFUVJGHKNGNKUVHQNNQYUVJGRCTGPVJGUGU$GECWUGPQ
URGEVTWOHKNGKURTQEGUUGFFWTKPIVJGOGCUWTGOGPVVJGXCNWGKU0QVG
VJCVCHKNGNKUVKUOCPFCVQT[HQT1275HWPEVKQPU
5GRCTCVGFD[CEQOOCCPFGPENQUGFKPDTCEGUKUVJGRCTCOGVGTNKUVQHVJG
HWPEVKQP 6JKU NKUV WUWCNN[ EQPUKUVU QH UGXGTCN RCTCOGVGTU UGRCTCVGF D[
EQOOCU+HPQRCTCOGVGTUCTGWUGFVJGDTCEGUYKNNDGGORV[
#RCTCOGVGTFGENCTCVKQPEQPUKUVUQHVJGCDDTGXKCVKQPQHVJGRCTCOGVGTCP
GSWCN UKIP CPF VJG RCTCOGVGT XCNWG +P ECUG VJG XCNWG CTG EJCTCEVGTU
VGZVVJG[OWUVDGJ[RJGPCVGF
# ENQUG DTCEMGV HQNNQYGF D[ C UGOKEQNQP KPFKECVGU VJG GPF QH VJG EQO
OCPFNKPG
6JGXCTKCDNGV[RGKU(+.'
6JGPCOGQHVJGXCTKCDNGCNYC[UJCUVQDGGPENQUGFD[VJG UOCNNGTCU
CPF ITGCVGTVJCP UKIPU8CTKCDNGUVJCVCTGCWVQOCVKECNN[IGPGTCVGFCTG
RTGEGFGFD[C&QNNCTUKIPVQFKUVKPIWKUJVJGOHTQOWUGTFGHKPGFXCTKCDNGU
6JGGSWCNUKIPKUOCPFCVQT[KPVJGECUGQH(+.'XCTKCDNGU
6JG GSWCN UKIP KU HQNNQYGF D[ VJG NKUV QH FCVC DNQEMU QH VJG UGNGEVGF HKNG
QPN[KPVJGECUGQH(+.'XCTKCDNGU+PQWTGZCORNGVJGHKNGEQPUKUVUQPN[
QHQPGURGEVTCNFCVCDNQEMVJGCDUQTDCPEGURGEVTWO#$+HCHKNGEQPUKUVU
QHUGXGTCNFCVCDNQEMUVJGUGCTGUGRCTCVGFD[EQOOCU
6JGGPFQHVJGNKPGKUKPFKECVGFD[CUGOKEQNQP
8) Now save the macro using the Store Macro button. In the Save File dialog, navigate to the directory you generated before and enter Measure
1 as file name. Click on Save.
9) Exit the Macro Editor by clicking on Exit.
10) You can display the macro using any kind of text editor (e.g. Notepad).
Note that the parameter section contains no entry; this also is a specific feature
of the Measurement function.
OPUS-NT Programming
65
Run the macro with the Run Macro command from the Macro pulldown menu.
6.3
Task
The macro should acquire a spectrum and perform a baseline correction. A
peak table should be generated from the result spectrum.
We will built on the macro Measure 1, which we wrote in chapter 6.2.
Macro Functions
This example uses no special macro functions.
OPUS Functions
Measurement, Baseline Correction, Peak Picking
Contrary to the Measurement command, the OPUS functions responsible for the
data processing need far less parameters. We recommend to always include all
parameters, as shown in our example, into the command line.
66
OPUS-NT Programming
The result of the Peak Picking function is stored in an extra data block
(peak report). This block is automatically added to the FILE variable:
FILE <$ResultFile 1> = AB, AB/Peak;
8) Save the macro by clicking on Store Macro. Contrary to the first example, the macro name has already been entered in the File Name field,
because we edited an existing macro. Change the file name to
Measure 2 and click on Save. Exit the Macro Editor.
OPUS-NT Programming
67
BPO=64});
PeakPick ([<$ResultFile 1>:AB], {NSP=9, PSM=1, WHR=0,
LXP=400.000000, FXP=4000.000000, QP8=NO,
QP9=0.200000, PTR=20.000000, QP4=NO, QP7=0.800000,
QP6=NO, QP5=80.000000, PPM=1, QP0=NO, QP3=4});
PARAMETER SECTION
6.4
Task
The macro Measure 2 should be expanded to perform three concurrent sample measurements. In addition, a background spectrum should be measured
prior to the data acquisition.
Macro Functions
StartLoop, EndLoop
If a sequence of functions is to be repeated several times, the problem could be
tackled by repeatedly including the code responsible for the function. However,
there is a more elegant solution. The StartLoop and EndLoop commands define
a loop with a counter (Loop Count), that repeats the code enclosed by these
commands as often as indicated by the counter.
OPUS Functions
Measurement, Baseline Correction, Peak Picking
Only a background spectrum acquisition is added. The same conditions as for
the sample measurement apply.
68
OPUS-NT Programming
the dialog box that appears next without changing any of the parameters
by clicking on OK. The following code will be appended to the macro:
MeasureReference (0, {EXP=Default.xpm,
XPP=C:\OPUS_NT\XPM});
3) Select the line as usual (one left-click with the mouse). Now move the
line to the beginning of the macro by clicking on the
button. Alternatively, double-click on the command line, and drag it to the top of the
list while holding the left mouse button down.
4) Next, we will include a command which is not part of the OPUS pulldown menu. Clicking on
inserts a blank line in the command window just below the first line
5) Press on the
box.
6) From the drop-down list choose the StartLoop command. Two additional parameter fields are displayed.
7) As Loop Count enter 3 and 0 in the Loop Index field. Both fields are
empty because no matching variables have been declared so far. Click
on OK.
StartLoop (3,0); is inserted.
OPUS-NT Programming
69
8) Create another blank line in the command window. Call up the Special
Macro Commands dialog and choose the EndLoop command. This
command requires only the Loop Index as a parameter. The Loop Index
links the EndLoop command to the correct StartLoop command; therefore, enter 0. Especially when several loops are used make sure the
correct StartLoop and EndLoop commands are linked.
9) Save the macro as Measure 3 and exit the Macro Editor.
610
OPUS-NT Programming
6.5
Task
Modify Measure 3 to pause between the repeated data acquisitions. Prompt
the user to insert a new sample before the next measurement.
Macro Functions
StartLoop, EndLoop, Message
The Message function displays a message in a dialog box either for a defined
time or until the user closes the dialog box.
Note: the option ON_PRINTER is not available in OPUS-NT 2.0.
OPUS Functions
Measurement, Baseline Correction, Peak Picking
This example introduces no new OPUS functions.
OPUS-NT Programming
611
OPUS-NT Programming
6.6
Task
So far we used a fixed Loop Counter for the command repetition. In your every
day work you might find it more suitable to let the user choose how many repetitions he actually needs upon launching the macro. This requires a variable
Loop Counter.
Macro Functions
StartLoop, EndLoop, Message, UserDialog
A numerical variable is used for the Loop Counter. The variable value will be
entered in a dialog box.
OPUS Functions
Measurement, Baseline Correction, Peak Picking
This example introduces no new OPUS functions.
OPUS-NT Programming
613
614
OPUS-NT Programming
OPUS-NT Programming
615
6.7
Task
So far data processing was only performed on spectra acquired with the same
macro. The following examples show, how to load spectra from disk. The first
example loads a spectrum and performs a baseline correction, followed by a
normalization.
Macro Functions
In OPUS-OS/2, only a special macro command was available for loading spectra. This is also supported by OPUS-NT for reasons of compatibility. In addtiion, the Load File command of OPUS-NT can be used in a macro. In the
following we will use both commands.
616
OPUS-NT Programming
OPUS Functions
Load, Baseline Correction, Normalization
In this example the OPUS function Load File will be used.
OPUS-NT Programming
617
6.8
Task
In the previous example only the file ABBOE05.0 was processed. To be able to
process several files the file name and its path must be stored in variables. We
define \OPUS_NT\DATA as the default directory.
Macro Functions
GetOpusPath, UserDialog
Two STRING variables are used to store the path and file name of the spectrum.
A user dialog will be used to allow the user to enter name and path. The
GetOpusPath function is used to determine the path of the OPUS main directory, which is the extended by the string \DATA.
OPUS Functions
Load, Baseline Correction, Normalization
We replace the file name and path statements of the Load function against variables.
618
OPUS-NT Programming
8) Replace the file name and directory statements in the Load command
line by the variables. Double-click on this line and then on the button at
the end of the line. This will open the OPUS Load File dialog.
9) Load any file from the directory. The parameter dialog box will be displayed again, listing the path and file name as the first two entries. Click
on the topmost field in the Assign Variable column. A drop-down list
replaces the entry field; choose the variable <Path> from this list.
10) Click on the cell below and select <File Name> as described above.
Closing the dialog box yields the following program line:
<$ResultFile 1> = Load (0, {DAP=<Path>,
DAF=<File Name>, INP=D:\OPUS\DEBUG\METHODS,
IFP=C:\OPUS_NT\\METHODS, INM=DEFAULT.TXD,
IFN=DEFAULT});
OPUS-NT Programming
619
PROGRAM SECTION
UserDialog (Load, STANDARD, EDIT:<Path>, EDIT:<File
Name>, BLANK, BLANK, BLANK,
BLANK, BLANK, BLANK, BLANK, BLANK, BLANK, BLANK,
BLANK, BLANK);
<$ResultFile 1> = Load (0, {DAP=<Path>, DAF=<File
Name>,
INP=D:\OPUS\DEBUG\METHODS,
IFP=D:\OPUS\Release\METHODS,
INM=DEFAULT.TXD, IFN=DEFAULT});
Baseline ([<$ResultFile 1>:Spec], {BME=2, BCO=0,
BPO=64});
Normalize ([<$ResultFile 1>:Spec], {NME=1,
NFX=4000.000000, NLX=400.000000, NWR=1});
PARAMETER SECTION
6.9
Task
The previous example will be expanded to be able to load and process multiple
files.
Macro Functions
GetOpusPath, LoadFile, UserDialog, StartLoop, EndLoop
Instead of the OPUS Load File command, we will use the equivalent macro
function LoadFile. This function is able to load one or several files.
OPUS Functions
Baseline Correction, Normalization
This example introduces no new OPUS functions.
620
OPUS-NT Programming
Exit the dialog box. The following line will be appended to the macro:
<File> = <Path>\<File Name>;
8) Insert a blank line into the command window and open the Special
Macro Commands dialog. Select LoadFile.
9) In case of the LoadFile macro command, you have to define a FILE
variable for the data file intended to be loaded by yourself. Open the
variable window by clicking on the Add Variable button.
10) Define a FILE variable Result. From the first Value list, choose the
spectrum block AB. Dont change the remaining two lists. Copy the
variable to the list by clicking Add and close the dialog box to get back
to the Special Macro Commands dialog.
OPUS-NT Programming
621
11) From the Variable list, select the newly generated variable
[<Result>:AB]. Choose <File> from the File Name field and
WARNING from the Option list. This will add the following line to
the macro:
[<Result>:AB] = LoadFile (<File>, WARNING);
You see that a File expression (including the data block type) can be
used as result file in a command line as well.
12) By using wildcards (* or ?) for the file name, we are able to load
more than one file that match the preselection. Hence, ABB*.0 will load
ABBOE05.0, ABBOE08.0 and ABBOE12.0. But we can state only one
variable for all files. In this case, the variable will automatically be
622
OPUS-NT Programming
13)
14)
15)
16)
expanded to an array variable, holding more that one value (in our
example files). Each value can be addressed using an index number (in
square brackets). The first index number is [0]. <xyz>[3] therefore
addresses the fourth value of the variable <xyz>.
There is an elegant and simple way to address the values of a FILE variable array: use the StartLoop command with the variable name as Loop
Counter. Open the Special Macro Commands dialog box and select
StartLoop.
The [<Result>:AB] variable is also included in the Loop Count list.
Select this entry and set the Loop Index to 0.
Add the OPUS functions Baseline Correction and Normalization, using
the [<Result>:AB] variable.
Finally, add the EndLoop command with a Loop Index 0 as the last
line, and save the macro as Load 3.
OPUS-NT Programming
623
4) Note that the pointer now is in line two. The window at the bottom
shows which variables have been changed by the command executed
before and their current values.
624
OPUS-NT Programming
OPUS-NT Programming
625
6) Return to the Macro page and execute the next command. The result is
shown in the window at the bottom: <File> now contains the result of
the combination of both STRING variables.
7) The next step will execute the LoadFile function. All three spectra will
be loaded, the variable <Result> holds three different files. The first
file is listed twice for reasons that will be explained later.
8) The next step, StartLoop does not seem to perform any action. However, the command initiates the triple repetition of the following commands. You can watch this when you continue to step through the
macro.
6.10
Task
This example shows you an alternative route to load and process several files.
This time we will make use of the OPUS Load File command.
626
OPUS-NT Programming
Macro Functions
GetArrayCount, UserDialog, StartLoop, EndLoop, ScanPath
ScanPath reads the content of a directory. You have to specify a directory and a
file name using wildcards (e.g. C:\OPUS_NT\DATA\ABB*.0). All matching
file names are stored as array in a STRING variable.
GetArrayCount evaluates the number of elements stored in an array variable,
which then can be used as Loop Counter to address these elements.
OPUS Functions
Load, Baseline Correction, Normalization
This example introduces no new OPUS functions.
2)
OPUS-NT Programming
627
<File list>[<Index>].
8) In the next line, <Index> must increase by 1 to read the next list element during the next cycle of the loop. Add a blank line to the macro
and enter:
<Index> = <Index> + 1;
628
OPUS-NT Programming
6) We wont execute the following two loop cycles step by step. Therefore, by double-clicking on the line number of line 7 (Baseline), a break
point will be set, indicated by a small stop sign.
7) Now click on Run to Breakpoint. As you can see, the second spectrum
will be loaded; during this operation the Debugger is grayed. Also,
<Index> now has a value of 2.
8) Repeat the Run to Breakpoint cycle. The last file is loaded and
<Index> now has a value of 3.
9) A third click on Run to Breakpoint performs the baseline correction and
ends the macro.
The main difference to the last example is, that the macro command LoadFile
loads all three spectra before processing them in the loop. In this example, the
files will be loaded subsequently, while the macro goes through the loop. In the
case of only three files, this may seem of minor importance. However, if you
process a great number of files you will notice, that loading the files turns out to
be quite time consuming. In this case, the latter method is the method of choice.
6.11
Task
So far all example macros either loaded or acquired the data prior to data processing. However, there is a multitude of applications in which you may want
to process data that was already loaded. In this example, we will demonstrate a
general route to this type of data processing.
Macro Functions
This example introduces no new macro functions.
OPUS Functions
Baseline Correction
This example introduces no new OPUS functions.
OPUS-NT Programming
629
6.12
Task
The previous macro will now be expanded by a user dialog box, from which
you can select the spectrum you want to process.
630
OPUS-NT Programming
Macro Functions
UserDialog
This example introduces no new macro functions.
OPUS Functions
Baseline Correction
This example introduces no new OPUS functions.
6.13
Task
OPUS-NT manipulates copies instead of the original file during data processing. Therefore, the result of a data manipulation has to be stored explicitly. We
will demonstrate in this example, how files can be saved using a macro. In
addition, we will use the OPUS Unload File command, which is used to reduce
the numbers of files loaded.
OPUS-NT Programming
631
Macro Functions
UserDialog
This example introduces no new macro functions.
OPUS Functions
Baseline Correction, Save As, Save, Unload
We will make use of both Save and Save As commands to store the data. Afterwards the file will be unloaded.
632
OPUS-NT Programming
6.14
Task
If you try to process more than one spectrum at a time with the previous example by dropping several files in the file selection field, you will note that only
the last spectrum of the file list will be processed. In the following macro we
will show how to handle more than one file.
Macro Functions
UserDialog, StartLoop, EndLoop
We use a loop to repeatedly process an array of files. As we have seen in Load
3 the StartLoop function is able to directly use an array as a Loop Counter.
OPUS Functions
Baseline Correction
This example introduces no new OPUS functions.
OPUS-NT Programming
633
6.15
Task
We expand the last macro to perform a peak pick on the baseline-corrected
spectrum. The frequency limits and the peak sensitivity should be kept variable.
Macro Functions
UserDialog, StartLoop, EndLoop
This example introduces no new macro functions.
OPUS Functions
Baseline Correction, Peak Picking
This example introduces no new OPUS functions.
OPUS-NT Programming
3) Select the Baseline command line and choose Peak Picking from the
OPUS Evaluate pull-down menu. Select <File> and make sure that
Use File Limits on the Frequency Range page is not selected.
4) After clicking on Peak pick, the parameter dialog opens. Assign the following variables:
<x-Start Frequency> to FXP
<x-End Frequency> to LXP
<Sensitivity> to PTR
5) Edit this user dialog box command in the first line. Add three Edit lines
for the numerical parameters.
6) Save the macro as Manipulation 4.
OPUS-NT Programming
635
6.16
Task
While most OPUS functions can be integrated into macros without any problems some functions require special consideration. One of these functions is the
Averaging function from the OPUS Manipulation pull-down menu which we
will use in the following two examples.
Usually, an OPUS function processes only one file at a time which is the reason
why these functions must be enclosed by a loop if several files should be processed. The average function uses several files at once to calculate an average
spectrum.
Macro Functions
UserDialog, StartLoop, EndLoop
This example introduces no new macro functions.
OPUS Functions
Average
The average function uses several files at once to calculate an average spectrum,
which is stored in a new file. To include this function in a macro, we make use
of the fact that an existing average spectrum can be updated.
636
OPUS-NT Programming
6) Choose the Averaging once more and select this time <Next Files>
as the spectrum to be averaged.
7) If you select the Update Average Spectrum parameter, you can pick the
average spectrum created during the first run ([<$Result File
1>:Spec]) from the list. This time the result is not stored in a new file,
but included in the average calculation during every cycle of the loop.
OPUS-NT Programming
637
8) Close the loop by appending the EndLoop command and save the macro
as Average 1.
638
OPUS-NT Programming
6.17
Task
In addition to the calculation of an average spectrum, it is possible to generate a
standard deviation spectrum and store it in a separate file. Similar to the average spectrum, it is possible to also update the standard deviation spectrum.
Macro Functions
StartLoop, EndLoop
This example introduces no new macro functions.
OPUS Functions
Average
This example introduces no new OPUS functions.
OPUS-NT Programming
639
5) Close the functions dialog box and save the macro as Average 2.
640
OPUS-NT Programming
6.18
Task
Accessing parameters and data of a spectrum file is a common task. In the following we will use macros to read out data from a spectrum file. In our first
example we read the sample name information from a file, add a charge number
and write the result to the file.
Macro Functions
GetParameter, UserDialog,
To read information from an OPUS file we use the GetParameter command,
which returns the parameter in a STRING variable. We use EnterExpression to
merge two text variables and plain text.
OPUS Functions
Edit Parameter
Only a few parameters of an OPUS file can be edited, due to security reasons.
For editing the parameters, the Edit Parameter function from the OPUS Edit
pull-down menu is available. However, this functions always saves the complete parameter set from the OPUS file. Therefore, we also have to read the
complete parameter set, regardless of the number of parameters we want to edit.
4) We have to write similar statements for the remaining parameters sample form (SFM), operator name (CNM) and sample number
(RSN). Pay special attention to define the correct index numbers.
<Sample Name>[1] = GetParameter ([<File>:AB], SFM);
OPUS-NT Programming
641
Either append this line manually or use the Special Macro Commands
dialog and EnterExpression. Make sure to include the correct index
number. As you can see you can combine variables and text in this type
of statement.
6) Select the Edit Parameter command from the OPUS Edit pull-down
menu. Choose [<File>:AB] from the Select File field and leave the
remaining fields blank. Click on Change and assign the variables in the
parameter dialog that appears next.
7) Save the macro as Parameter 1.
642
OPUS-NT Programming
6.19
Task
If you ever created you own library you know that the files you want to include
must have an information block. In general you probably stated the sample
name and the preparation method during the sample measurement. We can
expand the last macro and have it create an info block in addition.
Macro Functions
GetParameter, UserDialog,
This example introduces no new macro functions.
OPUS Functions
Edit Parameter, Information Input
We will use the Information Input function from the OPUS Edit pull-down
menu to append an information block to a spectrum (assuming that the spectrum
does not already include one).
OPUS-NT Programming
643
5) If you prefer to enter these parameters in the parameter dialog box, you
must enter a random character in the fields of the Information Input
dialog you want to access. Click on Add Information to switch to the
parameter dialog box and edit the entries.
6) If necessary, enter the variables in the fourth column. Keep in mind, that
<Sample Name> is an array variable for which you have to specify an
index value.
644
OPUS-NT Programming
OPUS-NT Programming
645
6.20
Task
The last macro always generated a new information block or replaced an existing information block. Now we will only change one or a few entries in an
existing block, in our example the compound name.
Macro Functions
This example introduces no new macro functions.
OPUS Functions
Information Input
This example introduces no new OPUS functions.
646
OPUS-NT Programming
T09=TEXT:Manufacturer,
T10=TEXT:Reference, T11=TEXT:Charge Number,
T12=TEXT:Comment});
PARAMETER SECTION
6.21
Task
Often it is necessary to read specific data from a report, which contains the
results of several data evaluation methods. In this example, we will extract the
number of peaks of a peak pick and subsequently use a loop to read the frequencies of the peaks which will be displayed in a message box. In addition, we will
format the output.
Macro Functions
StartLoop, EndLoop, Message, FromReportHeader, FromReportMatrix
We will use the FromReportHeader command to extract a value from the header
of a report. That requires to ascertain the position of the desired information
(here the number of peaks). In our case the number of hits is found in the third
row of the header.
Headers always consist of two parts: a title (e.g. number of hits) and the actual
value. The command FromReportHeader allows you to select either the title
(option: LEFT) or the value (option: RIGHT).
The FromReportMatrix command allows to read data from a matrix if the column number is known. We want to read frequency values which are located in
the first column.
Note: Both commands use the report and subreport parameters which should be
set to 1 and 0, respectively. Only a Quant and Ident report may consist of
several main reports and/or subreports. Refer to the manual of these software
packages for details.
We will demonstrate the use of characters in combination with a message box,
which are laos used as control characters in the command lines. Such a control
character will be interpreted as a printable character, if it is repeated twice; if
OPUS-NT Programming
647
you want to enclose the unit cm-1 by brackets, you achieve this by typing [[cm1]]. The following characters act as control characters:
< > [ ] { } ; , :
OPUS Functions
Peak Picking
This example introduces no new OPUS functions.
648
OPUS-NT Programming
6) We make use of the Message command to display the value, that was
read from the report block. Enter the following message text:
<Index>, Peak at <[,0]Peak Position>[[cm-1]].
Included in the command line is a statement to format the output; this
statement is enclosed in square brackets and defines the number of decimals in our example no digits after the decimal point. [,2] for example
would cause an output with two digits after the decimal point. However,
these statements only concern the text output and do not change the data.
Further information about text formatting can be found in the Macro
Reference section.
7) We avoid the necessity to confirm each message by setting the Time
parameter to 5. As a result, the message will be displayed for 5 seconds.
8) Next we increment the variable <Index> for the line number by 1:
<Index> = <Index> +1
9) Finally, the loop has to be closed by the EndLoop command.
10) Save the macro as Parameter 4.
OPUS-NT Programming
649
NUMERIC <Index> = 1;
NUMERIC <Peak Position> = 0;
PROGRAM SECTION
PeakPick ([<File>:AB], {NSP=9, PSM=1, WHR=1,
LXP=400.000000, FXP=4000.000000, QP8=NO,
QP9=0.200000, PTR=20.000000, QP4=NO, QP7=0.800000,
QP6=NO, QP5=80.000000, PPM=1, QP0=NO, QP3=4});
<Count> = FromReportHeader ([<File>:AB/Peak], 1, 0, 3,
RIGHT);
StartLoop (<Count>, 0);
<Peak Position> = FromReportMatrix ([<File>:AB/Peak],
1, 0, <Index>, 1);
Message (<Index>. Peak at <[,0]Peak Position> [[cm1]], ON_SCREEN, 5);
<Index> = <Index>+1;
EndLoop (0);
PARAMETER SECTION
6.22
Task
So far, we mostly wrote linear code, that is all command lines will be processed
subsequently. The first exception from a linear progression was introduced
with the loop command. Now we will learn how to tweak a macro program, in
order to make it flexible and more powerful.
Note that the following examples should only demonstrate the principle of how
to control the flow in a macro and therefore will only use Macro functions.
In our first example we will integrate two buttons (Button 1 and Button 2) in a
user dialog box to launch different actions. Clicking on the buttons will display
different messages, followed by the initial dialog box. The macro will only be
terminated by clicking on Continue.
650
OPUS-NT Programming
Macro Functions
Label, Goto, Message, User Dialog
We will define two BUTTON variables which are linked to different labels.
Clicking on the respective button in the user dialog box will then result in a
jump to one of these labels. The tweaks will be closed by the Goto command.
The Goto command allows to continue a macro at any line of the code that will
be indicated by a label. The label can be placed anywhere in the macro.
OPUS Functions
This example introduces no new OPUS functions.
As you can see, the variable is linked to a jump via the Goto command.
OPUS-NT Programming
651
choose <Button 1>. To display both buttons in the same line, type
+<Button 2> after the first variable name.
4) Each time you click on Continue in a user dialog box, the next program
line will be processed. We will redirect the macro to the last line by
inserting a Goto statement after the line containing the UserDialog command. Use end as label name. You will notice that a label with the
same name will automatically be created. We will move this label to the
end of the code in the last step.
5) Insert the label for the first jump:
Label (first)
6) Append a message that indicates the correct target like First Button
pressed. Set the Timer to 5 seconds.
7) After the delay time has expired the user dialog box should be displayed
again. Therefore, insert another Goto command with start as the label
name. Again, the label start is automatically generated. Move the
label to the top of the PROGRAM SECTION.
8) In a similar manner, add the label for the second button, its message and
the Goto statement.
9) Finally, move the line Label (end) to the last position of the macro.
10) Save the macro as Control 1.
652
OPUS-NT Programming
6.23
Task
We will modify Control 1, so that the default buttons (Continue, Help and
Cancel) wont be displayed in the user dialog box.
Macro Functions
Label, Goto, Message, User Dialog
We will use the option NODEFAULTBUTTON to suppress the default buttons
in the user dialog box.
OPUS Functions
This example introduces no new OPUS functions.
OPUS-NT Programming
653
6.24
Task
Simple program structures can easily be controlled by the Goto command. The
extensive use of Goto statements in longer macros can be confusing. The If
statement is a better way of structuring complex programs.
The following example analyzes several parameters entered in a user dialog
box:
654
OPUS-NT Programming
Check box: if the check box is selected by the user a message will be
displayed.
Drop-down list showing the options yes and no: if yes is chosen a message will be displayed.
Numerical field: the input of a numerical field will be compared to a
value (here greater than or equals 10) and the result will be displayed.
Text field: a text search will be performed using the input of the text
field on another predefined text and the result will be displayed.
Macro Functions
If, Else, Endif, Message, User Dialog, FindString
The If command compares two variables or values using several numerical or
text operators:
Numerical operators:
.EQ.
.GT.
.LT.
.GTEQ.
.LTEQ.
.NE.
tests identity
tests if value 1 is greater than value 2
tests if value 1 is smaller than value 2
tests if value 1 is greater than or equal to value 2
tests if value 1 is smaller than or equal to value 2
tests if value 1 is not equal to value 2
Text operators:
.NOCASE_PARTOF. tests if text 1 is included in text 2, the text is
not case-sensitive
.CASE_PARTOF.
OPUS-NT Programming
655
OPUS Functions
This example introduces no new OPUS functions.
be TRUE or FALSE)
STRING <Yes or No> = ;(no value defined)
NUMERIC <Test of Numbers> = 0;
STRING <Search in> = abcdefghijk;
STRING <Search for> = ;(no value defined)
NUMERIC <Result> = 0;
656
OPUS-NT Programming
4) Now the test sequences are included. First we will test if the check box
was selected in the user dialog. Include the If command and choose
<Checkbox> as the first variable. This variable has the value TRUE
if the check box has been selected, otherwise FALSE. Set the Condition to .EQ. and Variable 2 to TRUE.
5) In case the check box was selected the following message should be displayed:
Bruker Optik GmbH
OPUS-NT Programming
657
OPUS-NT Programming
OPUS-NT Programming
659
6.25
Task
When writing macros it is crucial to know if all functions are executed correctly. Making mistakes while writing your own macros will eventually be
unavoidable. Most of the OPUS and Macro functions will return an error code,
that can checked within a macro and can be used to change the flow in a macro.
In this example, we will use the OPUS Load File command which returns an
error message if the indicated spectrum is not found.
Macro Functions
If, Else, Endif, Message, User Dialog,
We use the keyword MACROERROR in combination with the If command to
test for errors. The If command must be placed right after the function to be
tested.
If MACROERROR is used with the message command, a specific error message will appear on the screen while running the macro.
OPUS Functions
Load, Baseline Correction, Normalize
This example introduces no new OPUS functions.
4) We would like the macro to proceed normally if no error occurs. Therefore, we include an Else(); statement.
5) Append an Endif(); statement to become the last line of the macro.
6) Save the macro as Control 3.
660
OPUS-NT Programming
6.26
Task
In certain situations a time control of the macro is desirable. Examples are certain actions, that should be launched or repeated at a given time or simply the
evaluation of the current date and time during run time.
We start by programming a clock that will turn itself off after a delay of one
minute.
Macro Functions
StartLoop, EndLoop, GetTime, StaticMessage, Timer
The GetTime function returns the current date and time. Separate variables are
used to return the year, month, day, hour, minute and second.
We will bundle the date and time in two text lines with the help of format functions, and display them in a static message box. Contrary to a regular message
Bruker Optik GmbH
OPUS-NT Programming
661
box, the static message wont interfere with processing the commands of the
macro. A repeated call of the static message refreshes the display or can be
used to hide the message. We will refresh the display every second. This is
done by placing the Timer command in a loop.
We format all variable output to two digits; include [2] as formatting command.
The result will be a leading 0 in case of one digit values, while only the last
two digits will be displayed if the value has more than two digits:
value of the variable: 1
value of the variable: 1999
displayed value: 01
displayed value: 99
OPUS Functions
This example introduces no new OPUS functions.
3) Open the Special Macro Commands dialog box and select the GetTime
function. Due to the large number of return values of this function, the
variables are passed as function arguments.
GetTime (<Year>, <Month>, <Day>, <Hour>, <Minute>,
<Second>);
4) Now select the StaticMessage command and leave the value of Option
set to SHOW. Enter an expression for the date in the first line:
<Date> = <[2]Day>.<[2]Month>.<[2]Year>;
In the second line, enter an expression for the time (note the double
colons):
<Time> = <[2]Hour>::<[2]Minute>::<[2]Second>;
662
OPUS-NT Programming
5) Append the Timer command with Option set to WAITTIME and Time
set to 1. This causes the macro to wait for one second.
6) Append an EndLoop statement and save the macro as Timer 1.
<Hour> = 0;
<Minute> = 0;
<Second> = 0;
<Year> = 0;
<Month> = 0;
<Day> = 0;
PROGRAM SECTION
StartLoop (60, 0);
GetTime (<Year>, <Month>, <Day>, <Hour>, <Minute>,
<Second>);
StaticMessage (SHOW, {<[2]Day>.<[2]Month>.<[2]Year>,
<[2]Hour>::<[2]Minute>::<[2]Second>});
Timer (WAITTIME, 1);
EndLoop (0);
PARAMETER SECTION
OPUS-NT Programming
663
6.27
Task
Another option of the Timer function allows to wait until a specified time has
been reached. In this example, we will evaluate the current time, add one
minute and pause the macro until the clock reaches this time. After one minute
has passed a message will be displayed.
Macro Functions
GetTime, Message, Timer
We will use the Timer command in combination with the WAITUNTIL keyword.
OPUS Functions
This example introduces no new OPUS functions.
4) Choose the Timer command from the Command Name list in the Special
Macro Commands dialog box and select WAITUNTIL in the Option
664
OPUS-NT Programming
field. Enter the new time in the HH:MM:SS format into the Time field:
<Hour>:<Minute>:<Second>
6.28
Task
Timer 2 has the disadvantage, that no commands are processed while the
macro pauses. The following macro presents an alternative way. As in Timer
2, we evaluate the current time and add one minute. But in addition a message
is displayed for 2 seconds, after every 10 seconds until the calculated time has
passed. Finally, a message showing the current time will be displayed.
Macro Functions
GetTime, Message, Timer, If, Else, Endif, Goto
We will use an If statement in combination with the TIME keyword.
OPUS-NT Programming
665
OPUS Functions
This example introduces no new OPUS functions.
SECTION
Label (Action);
666
OPUS-NT Programming
6.29
Task
The examples so far have been relatively simple. If you are facing a complex
task you will notice, that the total length of the macro increases rapidly. To
keep macros clearly structured and simple to read they should be divided into
small sub routines. These routines can be tested individually and independent
from the status of the main macro. The task of the main macro should therefore
be restricted to call these sub routines and exert the overall control.
Our first example, will be a main macro calling Measure 3 as a sub routine.
Before and after calling the sub routine messages should be displayed.
Macro Functions
RunMacro, Message
This example introduces no new Macro functions.
OPUS Functions
This example introduces no new OPUS functions.
2) From the OPUS pull-down menu, select the Run Macro command. A
load file dialog box will be displayed. Choose Measure 3 from the
Macro directory. Exit the parameter dialog box and append another
message:
OPUS-NT Programming
667
6.30
Task
The previous example can easily be implemented, but has its limitations. For
instance, data measured or loaded in the sub macro are not accessible from the
sub macro and vice versa. Also, parameter values cannot be exchanged
between both programs. These restrictions can be overcome by using the CallMacro command.
We will use the macro Manipulate 2, which performs a baseline correction on
a spectrum, as a sub routine and display two messages in the main macro, prior
to and after the data processing.
Macro Functions
CallMacro, GetMacroPath, UserDialog, Message
We will use the CallMacro command to access the sub routine. CallMacro is
able to forward variables to the routine via a user dialog box included in the sub
routine. This dialog box must contain these variables in the same order and
668
OPUS-NT Programming
with the same type in which they appear in the CallMacro command line. In our
example, we will exchange only one FILE variable.
We determine the path of the sub macro with the GetMacroPath command.
This command returns the path to the directory from which the main macro was
started (and which also must contain the sub macro). This ensures that macros
work independent of a specific directory structure.
OPUS Functions
This example introduces no new OPUS functions.
5) Select the CallMacro command from the Special Macro Commands dialog box. A new dialog box will be displayed. In the first field we enter
the path and file name of the sub macro to be called:
<Path>\manipulate 2.mtx
You dont have to enter the file name extension .MTX. This allows
you to either run macros in text or binary format without the need to
modify a macro.
The remaining two columns are used to define the parameter exchange.
In the left column, enter the parameter to be forwarded; select
[<File>:AB] from the list. The right column holds the returned
parameters. We dont need to make any entries here, exit the dialog by
clicking OK.
OPUS-NT Programming
669
6) Finally, include a message to indicate that the sub macro has been processed:
Message (Submacro has finished, ON_SCREEN,
NO_TIMEOUT);
OPUS-NT Programming
6.31
Task
In this example we will call two sub macros. The first sub macro generates a
new spectrum by multiplying a spectrum with the Spectrum Calculator. The
second sub macro is based on Parameter 4, which we will extend and save as
Submacro 2. This macro creates a peak table with variable frequency limits
and sensitivity. All values (the spectrum name, multiplication factor, and the
parameters for the peak picking) should be entered in the main macro by the
user and then forwarded to the sub macros. The peaks will be read from the
peak table and displayed in a message.
Macro Functions
CallMacro, GetMacroPath, UserDialog, Message, StartLoop, EndLoop,
FromReportHeader
This example introduces no new macro functions.
OPUS Functions
Spectrum Calculator, Peak Picking
We will use the Spectrum Calculator from the OPUS Manipulate pull-down
menu. This function always generates a new result file.
OPUS-NT Programming
671
3) Open the OPUS Manipulate menu and select the Spectrum Calculator.
Select the variable [<File>:AB] and multiplicate it by 2. Click on
the = sign. The parameter dialog box opens. We want to use a variable instead of a constant factor, therefore we need to modify the following line for the parameter FOR:
[<File>:AB]*<Factor>
12) Append the four NUMERICAL variables to the user dialog in line two.
13) Change the message text of the messages in line three and five to Submacro 1...
14) Edit the CallMacro command and change the name of the sub macro to
Submacro 1.mtx. Add <Factor> as second parameter to be
exchanged. Choose [<New File>:AB] from the Returned Paramters
list for the [<File>:AB] variable.
672
OPUS-NT Programming
OPUS-NT Programming
673
UserDialog (0, STANDARD, FILE:[<File>:AB], EDIT:<Factor>, BLANK, BLANK, BLANK, BLANK, BLANK, BLANK, BLANK,
BLANK, BLANK, BLANK, BLANK, BLANK);
<$ResultFile 1> = Calculator ([<File>:AB], {CDI=1,
FOR=[<File>:AB]*<Factor>});
UserDialog (0, STANDARD, FILE:[<$ResultFile 1>:AB],
BLANK, BLANK, BLANK, BLANK, BLANK, BLANK, BLANK,
BLANK, BLANK, BLANK, BLANK, BLANK, BLANK);
PARAMETER SECTION
674
OPUS-NT Programming
6.32
Task
The last two examples demonstrate how to handle data output. The first example simply writes three text lines to a file. This file should then be read and its
content displayed. Finally, we will delete the file.
Macro Functions
TextToFile, Message, StartLoop, EndLoop, Delete
TextToFile writes text line by line to a specified file. The text will either be
appended to an existing file, or a new file can be created to hold the text. The
reverse case involves using the ReadTextFile command. This command reads a
text file line by line and stores the content in an array.
A set of macro commands exist to copy, rename and delete files. We will use
the Delete command to delete the text file created before.
OPUS-NT Programming
675
OPUS Functions
This example introduces no new OPUS functions.
3) Get the current OPUS path using the GetOpusPath command and save it
in <Path>.
4) Expand the <Path> variable by the subdirectory WORK.
5) Select the TextToFile command from the Special Macro Commands dialog box. Fill in the following text:
Path
<Path>
File Name
Text.txt
Text
<Lines>[0]
Output Option REPLACE_TEXT
REPLACE_TEXT generates a new file or overwrites an existing one
with the same name.
6) Repeat these steps twice, each time incrementing the array counter of
the <Lines> variable.
Instead of REPLACE_TEXT use
APPEND_TEXT to append these lines to the file.
7) Append the ReadTextFile command to read the text file. In the Text File
Name field, enter <Path>\test.txt. Specify <Text> to hold the return
value.
8) Use the GetArrayCount command to determine the number of elements
contained in <Text>; save it in <Count>.
9) Start a loop using <Count> as loop counter.
10) Include an array element of <Text> in a message, use <Index> as
array index.
11) Increase <Index> by one and close the loop with EndLoop().
12) Append the Delete command. Only the path and file name is required as
parameter. State the file to be deleted by entering
<Path>\test.txt.
13) Save the macro as Output 1.
676
OPUS-NT Programming
STRING <Path> = ;
STRING <Lines> = ;
STRING <Text> = ;
NUMERIC <Count> = 0;
NUMERIC <Index> = 0;
PROGRAM SECTION
<Lines>[0] = Line 1;
<Lines>[1] = Line 2;
<Lines>[2] = Line 3;
<Path> = GetOpusPath ();
<Path> = <Path>\WORK;
TextToFile (<Path>, Test.txt, <Lines>[0],
REPLACE_TEXT);
TextToFile (<Path>, Test.txt, <Lines>[1],
APPEND_TEXT);
TextToFile (<Path>, Test.txt, <Lines>[2],
APPEND_TEXT);
<Text> = ReadTextFile (<Path>\Test.txt);
<Count> = GetArrayCount (<Text>);
StartLoop (<Count>, 0);
Message (<Text>[<Index>], ON_SCREEN, NO_TIMEOUT);
<Index> = <Index>+1;
EndLoop (0);
Delete (<Path>\test.txt);
PARAMETER SECTION
6.33
Task
We will demonstrate how to plot spectra in different ways. The first command
will plot two spectra in one frame. The second command draws two spectra in
two different frames.
Macro Functions
UserDialog
This example introduces no new macro functions.
OPUS-NT Programming
677
OPUS Functions
Plot
To plot spectra, we use the OPUS Print Spectra function from the Print menu.
5) In the same manner, add a second Plot command, this time using
FRAME2.PLE as template. It contains two frames labelled OBEN
(upper) and UNTEN (lower), between which you switch using the
pull down list. Assign [<File 1>:AB] to OBEN and [<File
2>:AB] to UNTEN. Exit the dialog by clicking on Plot. Now you
see, that in the command line generated this time the file names are separated by commas, indicating that they will be plotted in different
frames.
Plot ([<File 1>:AB], [<File 2>:AB], {...
678
OPUS-NT Programming
OPUS-NT Programming
679
680
OPUS-NT Programming
7.1
7.1.1
The Load function (Form_Load) serves to interpret a parameter, which contains a text command, as a program that is to be launched. This functionality is
used in the Basic program to start OPUS. The function connectToServer
opens the connection to OPUS.
Bruker Optik GmbH
OPUS-NT Programming
71
Option Explicit
Dim connected As Integer
Dim timeOut As Integer
Dim serverName As String
Private Sub Form_Load()
Dim BefZl
timeOut = 6000 in ~ tenths of a second
connected = 0
BefZl = Command()
If Len(BefZl) > 0 Then
Shell (BefZl)
End If
serverName = "OPUS|System"
connectToServer (serverName)
End Sub
Its main purpose is to initialize the DDE functionality of the ddeLink text box
object. First the LinkMode is set to vbLinkNotify, which is the asynchronous
mode (the Basic program does not pause). As soon as a command was processed by OPUS, the LinkNotify event of the ddeLink object will be activated. In general, this has proven to be useful, because otherwise the Basic
program will wait for a result to be returned and in the meantime will not process any input (e.g. like Cancel). By setting the LinkTopic to OPUS|System,
the Basic program rgistered a connection from the system with the given name.
If OPUS has been running, it has requested a DDE service using this name and
will function as a server. In addition, the LinkTimeout is defined.
Public Function connectToServer(server As String) As
Integer
connectToServer = 0
On Error GoTo connectToServerErr
ddeLink.LinkMode = vbLinkNotify
ddeLink.LinkTimeout = 100 give time for connection
ddeLink.LinkTopic = server
Set link topic.
ddeLink.LinkTimeout = timeOut
connectToServer = 1
connected = 1
ddeLink = "Connected to " + server
Exit Function
connectToServerErr:
connected = 0
ddeLink = Err.Description
Exit Function
End Function
7.1.2
Both routines, which are started by pressing one of the buttons have a similar
design. Important is the LinkItem, which is used to transmit a command to
OPUS as text.
In this case it is either TAKE_REFERENCE or
MEASURE_SAMPLE. Both commands expect the name of an OPUS experiment file, which defines the type of experiment.
72
OPUS-NT Programming
7.1.3
The LinkNotify routine is called as soon as OPUS has processed the command and supplies the result.
The LinkRequest call instructs OPUS to transfer the result to the ddeLink
object. Here, the result will only be displayed in the text box. This would also
be the handle for a data processing routine.
If a sample measurement has been started, the spectrum will be sent in the form
of a data point table.
Private Sub ddeLink_LinkNotify()
On Error GoTo requestErr
ddeLink.LinkRequest
Exit Sub
End Sub
7.1.4
Error Handling
OnErrorGoto has already been used in the routines described above. If the
connection should terminate or if an error occurs, the sub routines for the
respective events is called. In our example, the messages will only be displayed.
Private Sub ddeLink_LinkClose()
ddeLink = "Connection closed"
connected = 0
End Sub
OPUS-NT Programming
73
7.1.5
Program Termination
Upon termination, the form will be unloaded; in our example the unload function also illustrates the possibility to close OPUS.
Private Sub Exit_Click()
Unload Form1
End Sub
Private Sub Form_Unload(cancel As Integer)
On Error GoTo requestErr
ddeLink.LinkExecute "CLOSE_OPUS"
Exit Sub
requestErr:
ddeLink = Err.Description
Exit Sub
End Sub
7.2
74
OPUS-NT Programming
7.2.6
Establishing a Connection
Besides the declaration of variables, the first part of the program mainly serves
to establish a Named Pipe connection. First, the name of the Pipe is determined.
OPUS opens a Pipe with the name of the program that was launched. This
name can be accessed as argv[0] and will be added to \.\\PIPE\.
Then a loop tries repeatedly to open the Pipe, using the fopen command. If a
connection could not be established, the loop will be terminated after a predefined amount of time and the program stops.
#include
#include
#include
#include
#include
int
float
FILE
char
char
char
char
char
long
double
time_t
<stdio.h>
<stdlib.h>
<string.h>
<math.h>
<time.h>
main(int argc, char **argv){
*data;
*opuspipe;
buffer[255];
filename[255];
blocktyp[255];
pipename[255];
*progname;
i, numofpoints, entrynum;
freqfirstp, freqlastp, scalef;
starttime;
avail=0;
strcpy(pipename, "\\\\.\\PIPE\\");
progname=argv[0]; /* Remove Path */
if (strchr(progname,:))
progname=strchr(progname,:)+1;
while (strchr(progname,\\))
progname=strchr(progname,\\)+1;
strncat(pipename,progname,255);
starttime=time(NULL);i=0;
while(difftime(time(NULL),starttime)<timeout){
i++; /* num of tries */
errno=0;
if ((opuspipe = fopen(pipename, "rb+")) != NULL)
break;}
if(difftime(time(NULL),starttime)>=timeout)
cserror("Timeout - Pipe Open \n");
7.2.7
Client/Server Commands
OPUS-NT Programming
75
using the fseek command. Then fprint writes the command to be transmitted to the Pipe, which is sent immediately by the fflush command. Fwaitgets transfers the results line by line and also performs an error check.
The program expects a spectrum file indicated on the Select Program page
of the External Program function, which will be read by the
READ_FROM_ENTRY command. DATA_VALUES sets the appropriate
mode, and READ_DATA reads the spectral data.
The data will be stored in an array of a size depending on the number of data
points.
entrynum =1; /* The first file selected in the C/S
box*/
fseek(opuspipe,0,SEEK_SET);
fprintf(opuspipe,"READ_FROM_ENTRY %d\n",entrynum);
fflush(opuspipe);
fwaitgets(buffer, 255, opuspipe);
if (strcmp(buffer,"OK\n"))
cserror(buffer); /* C/S sent an error code */
fwaitgets(filename, 255, opuspipe);
fwaitgets(buffer, 255, opuspipe);/* contains file number */
fwaitgets(blocktyp, 255, opuspipe);
fseek(opuspipe,0,SEEK_SET);
fprintf(opuspipe,"DATA_VALUES\n");
fflush(opuspipe);
fwaitgets(buffer, 255, opuspipe);
if (strcmp(buffer,"OK\n"))
cserror(buffer);
fseek(opuspipe,0,SEEK_SET);
fprintf(opuspipe,"READ_DATA\n");
fflush(opuspipe);
fwaitgets(buffer, 255, opuspipe);
if (strcmp(buffer,"OK\n"))
cserror(buffer);
fwaitgets(buffer, 255, opuspipe);
sscanf(buffer,"%ld",&numofpoints);
fwaitgets(buffer, 255, opuspipe);
sscanf(buffer,"%lf",&freqfirstp);
fwaitgets(buffer, 255, opuspipe);
sscanf(buffer,"%lf",&freqlastp);
fwaitgets(buffer, 255, opuspipe);
sscanf(buffer,"%lf",&scalef);
if ((data=(float*)malloc(numofpoints*sizeof(float)))
==NULL)
cserror("Out of memory\n");
76
OPUS-NT Programming
7.2.8
Data Manipulation
After all data has been read from the OPUS file it is available for processing by
the program. In our example the data will only be mutliplied by 2. After the
data processing, all data will be written back to the same file. The PRESERVE
mode which existed in OS/2, is now obsolete due to the different approach of
Windows NT not to manipulate original data.
WRITE_TO_FILE/BLOCK specifies the block type of the target file and
WRITE_DATA initiates the write process. Because the spectral data file has
been altered by the program, it will be labelled "processed" in the OPUS user
interface; if the file was displayed, the display will be refreshed.
/* manipulate the data */
for (i = 0; i < numofpoints; i++)
data[i]*= 2.0;
/* Now Write it Back */
fseek(opuspipe,0,SEEK_SET);
fprintf(opuspipe,"PRESERVE\n"); /* will increment
extension */
fflush(opuspipe);
fwaitgets(buffer, 255, opuspipe);
if (strcmp(buffer,"OK\n"))
cserror(buffer);
fseek(opuspipe,0,SEEK_SET);
fprintf(opuspipe,"WRITE_TO_FILE %s",filename);/* filename contains end of line char !*/
fflush(opuspipe);
fwaitgets(buffer, 255, opuspipe);
if (strcmp(buffer,"OK\n"))
cserror(buffer);
fwaitgets(buffer, 255, opuspipe);/* contains path +
filename */
fwaitgets(buffer, 255, opuspipe);/* contain fileno */
fseek(opuspipe,0,SEEK_SET);
fprintf(opuspipe,"WRITE_TO_BLOCK %s", blocktyp);/*
blocktyp contains end of line char !*/
fflush(opuspipe);
fwaitgets(buffer, 255, opuspipe);
if (strcmp(buffer,"OK\n"))
cserror(buffer);
OPUS-NT Programming
77
fseek(opuspipe,0,SEEK_SET);
fprintf(opuspipe,"WRITE_DATA\n");
fflush(opuspipe);
fwaitgets(buffer, 255, opuspipe);
if (strcmp(buffer,"OK\n"))
cserror(buffer);
fseek(opuspipe,0,SEEK_SET);
fprintf(opuspipe,"%ld\n",numofpoints);
fprintf(opuspipe,"%lf\n",freqfirstp);
fprintf(opuspipe,"%lf\n",freqlastp);
fprintf(opuspipe,"%lf\n",scalef);
fflush(opuspipe);
for (i = 0; i < numofpoints; i++){
fprintf(opuspipe,"%f\n",data[i]); }
fflush(opuspipe);
fwaitgets(buffer, 255, opuspipe);
if (strcmp(buffer,"OK\n"))
cserror(buffer);
free(data);
fclose(opuspipe);
return (0); }
7.2.9
The program uses fwaitgets to read a line of data. However, this can pose a
problem, if the complete data set is not yet available or if not all characters have
been transferred. Especially a data request happening too early could cause the
program to hang, regardless whether the data is being written to the pipe on the
server side.
In this aspect the following code is more robust, but requires the use of Windows NT system calls. Because a Pipe is opened similar to a file, a variable of
type FILE is used in C to access the Pipe. However, API functions use a system-specific handle instead of this type. First of all, one has to find out the handle of the FILE variable. The API function PeekNamedPipe checks if the data
is already available. If so, getc is used to read the data; otherwise, the routine
times out.
#include <windows.h>
typedef struct {
long osfhnd;
/* underlying OS file HANDLE */
char osfile;
/* attributes of file (e.g.,
open in text mode?) */
char pipech;
/* one char buffer for handles
opened on pipes */
#if defined (_MT)
int lockinitflag;
CRITICAL_SECTION lock;
78
OPUS-NT Programming
OPUS-NT Programming
79
startzeit=time(NULL);}}
else{
buf[i] = fgetc(opuspipe);
avail--;
startzeit=time(NULL);}
if (buf[i]==\n){
i++;
break;}
}
buf[i]=0;
return (buf);}
7.2.10
The last example already pointed out some changes to programs running on
OS/2:
7.2.11
Miscellaneous
Identifying the Pipe name during the run time of your program (using a system
function) therefore ensures higher stability.
If Pipe was selected as communication method, OPUS expects your program
to open the Pipe; otherwise an error message will be the result. OPUS closes
the Pipe as soon as your program terminates the connection (end of program or
connection failure).
710
OPUS-NT Programming
It is not recommended to open several Pipes by the same program, for example
by starting the same program more than once. The result would be several
Pipes with the same name.
In principle, a connection via a network is possible. In this case, the computers
network name has to be used instead of the decimal in the Pipe name:
\\OPUSPC\PIPE\OPUS
OPUS-NT Programming
711
712
OPUS-NT Programming
VisualBasic Script
Creating Scripts
In this section you will learn more about the OPUS Scripting Editor. All of the
examples discussed in this chapter are included on the OPUS CD. The scripts
are written in VBScript and show how to call OPUS functions, start a measurement, access spreadsheets and OPUS data files or how to work with timers and
DDE communication. Make sure you are granted the right to work with VisualBasic scripts (see User Settings dialog).
8.1
VisualBasic Script
A script always consists of a form and program code. The form and the control
elements are configurable and are associated to program routines. The first
example (first.obs) shows how to process a data file and assign a button to this
routine.
8.1.1
Open the Scripting Editor as described in chapter 1.3.3. Click on the button
icon of the Toolbox to activate the CommandButton function. Hold down the
left mouse key on the form and move the mouse to create a rectangle for the
button you want to include. Upon releasing the mouse key, the button will be
inserted at this position. You can reposition it by left-clicking on it and moving
the mouse; to resize the button, click on the small squares on its border.
If you right-click on the button, you open a pop-up menu through which you can
access the Properties dialog of the button. Through this dialog, the properties
like color and font of the control element can be changed. Enter the text which
you would like to be displayed on the button in the Caption field. Pressing
Apply confirms these changes.
OPUS-NT Programming
81
Creating Scripts
8.1.2
In the next step a sub routine will be linked to an event of the button you have
just created. Switch to the code window by clicking on the
icon. You will
be presented with an empty work space and two drop-down lists. The left list
already contains available objects including the entry CommandButton 1.
82
OPUS-NT Programming
VisualBasic Script
From the Event list on the right side you can choose the events associated with
the button. Select the event you want to assign to a sub routine An event routine code will be included (here the routine for the event click, representing a
mouse click). A comment in the code indicates, were you have to include additional statements.
The routines to be performed upon this mouse click are to be called by the event
routine click. In case OPUS is to process a file, the OpusCommand function
is to be used, that forwards the text commands to OPUS:
Sub CommandButton1_Click
Form.OpusCommand("Baseline
([""E:\opus\data\abboe05.0""],{})")
End Sub
Note the double hyphenation within the command. This is caused by the fact,
that the file name has to be enclosed in hyphens, but the script also uses hyphens
to indicate text.
Now start the program by clicking on
; the form will be displayed, and the
Go button is active. If you click on it, OPUS will perform a baseline correction.
If no data file has been loaded so far, OPUS loads the file automatically. Switch
back to the editing mode by clicking on
. Save your work under any name
but with the extension .obs (OPUS Basic Script), using the Save command in
the File menu.
The user right to modify scripts can be assigned in the User Settings dialog; if
this right was not granted, the user is able to only run the script and is able to
perform only the actions defined by the script.
Bruker Optik GmbH
OPUS-NT Programming
83
Creating Scripts
8.1.3
OPUS Functions
Any OPUS function can be included in a text as shown in the example above.
Because of the complexity of the functions and function arguments, a shortcut
exists to define OPUS functions in a script.
Position the cursor in the section of the code, where you wish to include the
function; then simply start the function from the OPUS tool bar of the user
interface. A dialog differing slightly from the regular one will be displayed.
Instead of the usual file selection box, you see an entry field, in which you can
enter the file parameter to be used in the script. Clicking on Correct will result
in the insertion of the OPUS function into the script.
All parameters of the OPUS function can be defined as usual on the dialog
pages. They will be translated to code and appear in the script.
8.1.4
Performing Measurements
The graphical user interface generated by the Basic program in chapter 4.1 can
also be generated in a script. Create three buttons and label them Reference,
Measure and Cancel, as well as a text box for text output.
Set the parameter MultiLine of the text box Properties to true, to ensure,
that long text output will be written line by line. The part of the Basic program,
which handles the DDE communication can be omitted in the script. The script
is terminated with the function Close:
Sub CommandButton1_Click
Form.OpusCommand("TAKE_REFERENCE xxx.xpm")
End Sub
84
OPUS-NT Programming
VisualBasic Script
Sub CommandButton2_Click
Form.OpusCommand("MEASURE_SAMPLE xxx.xpm")
End Sub
Sub CommandButton3_Click
Form.Close
End Sub
Sub Form_OnOpusResult( ByVal strResult , ByVal
m_strResult2 , ByVal m_strResult3 , ByVal m_binData )
TextBox4.Text = strResult + m_strResult2 +
m_strResult3
End Sub
The script makes use of another form function: if a command is processed, the
function OnOpusResult will be called, which is an element the form. The result
of the OPUS command will be forwarded to this routine and in this example
will be written as text to the text box. In case of a terminated measurement this
could look like:
The resulting data file consists of a header, comprising the file name, a number,
the data block type, and the x and y axis units and the data points.
8.1.5
Accessing Spreadsheets
The following example illustrates how OPUS data can be exported to an Excel
spreadsheet. The Excel program must be installed on your computer. The program is started by the script with the CreateObject("Excel.Sheet") call;
the following command activates the program, which so far is running as a
background task, and Cells addresses the Excel table cells.
OPUS-NT Programming
85
Creating Scripts
Dim ExcelSheet
Sub CommandButton1_Click
Set ExcelSheet = CreateObject("Excel.Sheet")
ExcelSheet.Application.Visible = true
ExcelSheet.ActiveSheet.Cells(1,1).Value = "Hello
World"
End Sub
Further information about which objects and functions (e.g. in Word) are accessible in this way, can be found in the documentation of the Microsoft Office
package.
8.1.6
A timer object is used to control timed events. While the timer is not visible
during run time, it triggers events after a preset amount of time has elapsed.
The timer object is placed in the form and the time interval is set in milliseconds.
In the following example, the graphic output of the Infometrix software InStep
will be called repeatedly. This also demonstrates how to use the External Program function to establish a DDE connection. Because DDE communication is
not supported in scripts, the OPUS function is used in its text command form.
The file ddetest.obs can be found on your OPUS CD; to use the script, you need
the InStep software and you have to adjust the path to reflect your environment.
The form consists of two buttons to start and stop the repeated addition of data.
Dim command
Sub CommandButton1_Click
command =1
Form.OpusCommand("ExternalProgram(0,{XPR=F:\instep\instep.exe, XST=2, XCW=0,
DDE=0})")
End Sub
Sub Timer1_Timer
command=2
Form.OpusCommand("ExternalProgram(0,{XST=3, DDE=1,
DDS=INSTEP, DDT=DATA, DDI=MacroFile,
DDD=""f:\instep\examples\plat.stp""})")
End Sub
Sub CommandButton2_Click
Timer1.Interval=0
End Sub
Sub Form_OnOpusResult( ByVal strResult , ByVal
m_strResult2 , ByVal m_strResult3 , ByVal m_binData )
if command =1 then
Form.OpusCommand("ExternalProgram(0,{XST=3,
DDE=1, DDS=INSTEP, DDT=DATA, DDI=DataFile,
86
OPUS-NT Programming
VisualBasic Script
DDD=""f:\instep\examples\gasoline.dat""})")
Timer1.Interval = 10000
command =3
end if
if command =2 then
Form.OpusCommand("ExternalProgram(0,{XST=3,
DDE=1, DDS=INSTEP, DDT=DATA, DDI=Run, DDD="" ""})")
command =4
end if
End Sub
8.1.7
OPUS-NT Programming
87
Creating Scripts
Dim data(10000)
Sub CommandButton1_Click
result= Form.OpusRequest("BINARY")
TextBox2.Text= result
result1= Form.OpusRequest("FLOAT_MODE")
TextBox2.Text= TextBox2.Text+ result1
result2= Form.OpusRequest("FLOATCONV_MODE ON")
TextBox2.Text= TextBox2.Text+ result2
result3= Form.OpusRequest("READ_FROM_FILE
"+TextBox1.Text)
TextBox2.Text= TextBox2.Text+ result3
result4= Form.OpusRequest("READ_FROM_BLOCK AB")
TextBox2.Text= TextBox2.Text +result4
result5 = Form.OpusRequest("DATA_POINTS")
TextBox2.Text= TextBox2.Text+result5
result6 = Form.OpusRequestData("READ_DATA",data)
TextBox2.Text= TextBox2.Text+result6
for i = 1 to UBound(data)
data(i)= 2*data(i)
next
After data modification, WRITE_DATA writes it back to the file; this shows,
that the process of writing data can be split into several commands.
result7 = Form.OpusRequest("WRITE_TO_FILE
"+TextBox1.Text)
TextBox2.Text= TextBox2.Text+result7
result8 = Form.OpusRequest("WRITE_TO_BLOCK AB")
TextBox2.Text= TextBox2.Text+result8
result9 = Form.OpusRequest("WRITE_DATA")
TextBox2.Text= TextBox2.Text+result9
result10 = Form.OpusRequestData(CStr(UBound(data))+chr(10)+"1"+chr(10)+
CStr(UBound(data))+chr(10),data)
TextBox2.Text= TextBox2.Text+result10
The rest of the script demonstrates, how to access a report block; for this purpose, PeakPick is employed to create a peak table in report format.
REPORT_INFO, HEADER_INFO and MATRIX_INFO determine the dimensions of the report, header and matrix, respectively. The actual elements of the
report are addressed using HEADER_ELEMENT and MATRIX_ELEMENT.
Result13 = Form.OpusRequest("COMMAND_LINE PeakPick
(["""+TextBox1.Text+""":AB], {NSP=9, PSM=1, WHR=0,
LXP=400.000000, FXP=4000.000000, QP8=NO,
QP9=0.200000, PTR=20.000000, QP4=NO, QP7=0.800000,
QP6=NO, QP5=80.000000, PPM=1, QP0=NO, QP3=4});")
TextBox2.Text= TextBox2.Text+result13
result14= Form.OpusRequest("READ_FROM_BLOCK AB/Peak")
TextBox2.Text= TextBox2.Text +result14
result15= Form.OpusRequest("REPORT_INFO")
TextBox2.Text= TextBox2.Text +result15
88
OPUS-NT Programming
JavaScript
result16= Form.OpusRequest("HEADER_INFO")
TextBox2.Text= TextBox2.Text +result16
result17= Form.OpusRequest("MATRIX_INFO")
TextBox2.Text= TextBox2.Text +result17
result18= Form.OpusRequest("MATRIX_ELEMENT 1 0 1 1")
TextBox2.Text= TextBox2.Text +result18
result19= Form.OpusRequest("HEADER_ELEMENT 1 0 1")
TextBox2.Text= TextBox2.Text +result19
End Sub
Sub Form_OnLoad
TextBox1.Text = "E:\opus\data\abboe05.0"
End Sub
8.2
JavaScript
Although the Scripting Editor was intended for writing VisualBasic scripts, it
can be used as well to generate Java scripts. Therefore, the parameter
ActiveEngine of the forms Properties dialog has to be set to JScript.
Writing Java scripts works the same way as writing VisualBasic scripts, you
just have to take into account the specific Java commands. The procedures for
calling OPUS functions from within a form are identical. The declaration of
functions is slightly different, as you can see from a comparison of the following code (JSCRIP1.OBS).
Java:
function CommandButton1::Click( )
{
Form.OpusCommand("NEW_WINDOW 0")
}
VisualBasic:
Sub CommandButton1_Click
Form.OpusCommand("NEW_WINDOW 0")
End Sub
OPUS-NT Programming
89
Creating Scripts
810
OPUS-NT Programming
VARIABLES Section
9.1
VARIABLES Section
This section is reserved for the variable declaration in a macro. Only one declaration per line is allowed. Each line must be terminated by a semicolon. Variables can be of different type. The syntax of the declaration depends on the
variable type and is explained in the following sections. STRING, NUMERIC
and BOOL and FILE variables can hold a single value as well as an array of values.
General Syntax:
Type <Name> = Value;
Typekeyword for the variable type.
<Name>variable name.
Valueinitial value of the variable.
Variable values can be changed while running a macro in different ways:
OPUS-NT Programming
91
if this is the first assignment for this variable the elements 0, 1 and 2 will be
automatically set to 0.
Usually, the initial value of a variable is declared in the VARIABLES section
and will be used whenever a macro is started. Some applications require to
revoke any changes made to a variable during the last macro run. This can be
achieved by marking the variable.
9.1.1
Variable Types
9.1.2
92
OPUS-NT Programming
VARIABLES Section
Type
Name
Value
Examples:
NUMERIC <Index>;
STRING <Path> = d:\data;Do not forget to use single quotes for string
variable values.
BOOL <Plot?> = TRUE;
Note: The declaration stays the same for variables used as an array type but the
array values must be set within the PROGRAM section.
Usage of variables: Simply use the name of the variable enclosed in brackets
< >.
9.1.3
Name
Block n
Examples:
FILE <Input File>;
OPUS-NT Programming
93
9.1.4
Name
Label
Note: Neither the name of the button nor the label for the jump can be changed
while executing the macro.
Example:
BUTTON <Plot> = Goto (Plot Spectrum);
9.1.5
Values assigned in the variables section are the initial values whenever a macro
is started.
Some cases require, that the variables changed during a run are stored as new
initial values for the next run of the macro. You can do this by marking a variable by a preceding *. After executing a macro or by using the macro command SaveVars, all marked variables are updated to keep their last value.
Only variables of type STRING, NUMERIC and BOOL can be marked.
94
OPUS-NT Programming
VARIABLES Section
Example:
*STRING <Text 1> = Initial Text;this variable
.......
<Text 1> = New Text;
will be updated to New Text
*STRING <Text 1> = New Text;
and after running the macro, the
9.1.6
Special Characters
Some characters in the macro system are used as control characters in command
lines (e.g. {}[] ). With two exceptions these characters can be used as all other
characters as long as the text is enclosed in single quotes (e.g. 123 [g]).
Exceptions:
Smaller/greater sign < and >
Single quotes
To uses these characters within a text line simply enter them twice
Example:
To print a text like
To print a text like
Square brackets
123 [g]
OPUS-NT Programming
95
9.2
PROGRAM Section
The PROGRAM section is the part of the macro, where command lines are
stated. Command lines can be native OPUS Commands, special macro commands or variable assignments.
9.2.1
The PROGRAM section consists of several program lines, terminated by semicolons. Each individual line consists of at least three parts:
CommandName (Argument 1, Argument 2, ....);
CommandName
Argument n
Semicolon
Some Commands are used to assign values to variables. These commands are
preceded by the variable name followed by an equals sign.
<Variable> = CommandName (Argument 1, Argument 2, ....);
<Variable>
9.2.2
Command Names
Command names can either be native OPUS Commands or special macro commands. The commands are listed and described in detail in this chapter and
chapter 10.
9.2.3
Command Arguments
Text or Numbers
Any text or numbers are forwarded to the command, either as fixed values or as
variables.
96
OPUS-NT Programming
PARAMETER Section
Keywords
Keywords are specific instructions required for a command. Keywords are
always printed in capital letters, e. g. the time behavior of a message is determined by the keyword NO_TIMEOUT.
File
A file argument forwards the file, which is to be processed to the command. A
file argument is always enclosed in square brackets and requires the name of the
file variable and (separated by a colon) the name of the data block.
[<variable name>:Blocktype]
Example:
[<Input File>:AB]
or
[<Result>:AB/Peak]
Parameter List
This argument type is mainly needed for OPUS commands and is required, if
parameters must be changed during macro execution. A parameter list is
enclosed in braces. For each parameter in the list, the three letter parameter
name and the parameter value is separated by an equals sign. The parameter
values can consist of constants or variables. The different parameters are separated by commas.
{PA1=Value1, PA2=Value2, PA3=Value3, ....}
Return Value
Some commands (e.g. the Measurement or the Load function) return a
value, which has to be assigned to a variable.
These command are preceded by the variable name and an equals sign:
<Variable Name> = Command (Argument 1, Argument2, ...);
[<Variable Name>:Block ID] = Command (Argument 1, Argument2, ...);
9.3
PARAMETER Section
OPUS-NT Programming
97
Value
9.4
C
CallMacro
Copy
D
Delete
DisplaySpectrum
E
Else
Endif
EndLoop
Expressions
F
FindString
FromReportHeader
FromReportMatrix
G
GetArrayCount
GetEnumList
98
OPUS-NT Programming
GetDisplayLimits
GetLength
GetMacroPath
GetOpusPath
GetParameter
GetTime
GetUserPath
GetVersion
Goto
I
If
L
Label
LoadFile
M
Message
O
OpenDisplayWindow opens a new window for all result files
P
PrintToFile
R
ReadTextFile
Rename
S
SaveVars
ScanPath
SetDisplayLimits
StartLoop
OPUS-NT Programming
99
StaticMessage
T
TextToFile
Timer
U
UnDisplaySpectrum
UserDialog
9.5
hides a spectrum
shows a user-defined dialog box
System Functions
GetOpusPath
GetUserPath
GetMacroPath
GetVersion
GetArrayCount
GetLength
FindString
CallMacro
SaveVars
910
OPUS-NT Programming
StaticMessage
UserDialog
Input Functions
Enter Expression
FromReportHeader
FromReportMatrix
GetEnumList
GetParameter
ReadTextFile
Output Functions
PrintToFile
TextToFile
File Functions
Copy
Delete
Rename
LoadFile
ScanPath
Display Functions
OpenDisplayWindow opens a new window for all result files
CloseDisplayWindow closes a display window which had been opened with
OpenDisplayWindow
DisplaySpectrum
shows a spectrum on screen
UnDisplaySpectrum hides a spectrum
GetDisplayLimits
retrieves the current display limits of the macro display
window
SetDisplayLimits
sets the display limits for the current macro display
window
SetColor
sets the color of the specified spectrum on the display.
OPUS-NT Programming
911
9.6
System Functions
System Functions are used to access system values, like for example path
names. The following functions are available:
CallMacro
FindString
GetArrayCount
GetLength
GetMacroPath
GetOpusPath
GetUserPath
GetVersion
CallMacro
SaveVars
9.6.1
GetOpusPath
Retrieves the base path from which OPUS was started. The OPUS version
number is of type YYYYMMDD (e.g. 19990924).
To allow the design of macros that are machine independent, the path of the
OPUS folder can be retrieved at run time and read into a variable. Instead of
using fixed path names in a macro, we recommend using this path variable
instead.
Syntax:
<Variable> = GetOpusPath ();
<Variable>
The variable must be of the type STRING. The path is returned without backslash at the end. If you want to specify a subdirectory of OPUS, you have to
insert the backslash between the variable name and the subdirectory name (e.g.
<OPUS Path>\methods).
9.6.2
GetUserPath
Retrieves the path to the user specific files and folders of the user currently
logged in.
If no user (user name blank at login) is specified, the function acts like the function GetOpusPath and returns the current OPUS path.
912
OPUS-NT Programming
System Functions
To allow to write portable macros, the user specific path can be read into a variable. Instead of using fixed path names in a macro, we recommend to use this
path variable instead.
Syntax:
<Variable> = GetUserPath ();
<Variable>
The variable must be of the type STRING. The path is returned without backslash at the end. If you want to specify a subdirectory of your user path, you
have to insert the backslash between the variable name and the subdirectory
name (e.g. <User Path>\data)
9.6.3
GetMacroPath
Retrieves the path to the directory that holds the macro currently running and
saves it in a STRING variable.
Syntax:
<Variable> = GetMacroPath ();
<Variable>
9.6.4
GetVersion
9.6.5
GetArrayCount
<Variable 2>
OPUS-NT Programming
913
9.6.6
GetLength
<Variable 2>
Example:
STRING <text> = Hello world;
NUMERIC <length> = 0;
<length> = GetLength (<text>);
<length> has the value 11.
9.6.7
FindString
Finds a specified text within a STRING variable and returns the position of the
first character of the search text, starting with zero for the first character of the
STRING variable. The return value can be used directly in a text format command. If the search text is not found -1 will be returned.
Syntax:
<Variable 1> = FindString (<Variable 2>, Text, Option);
<Variable 1>
<Variable 2>
Text
string, to be searched.
Option
Example:
STRING <text> = This is the content of a STRING
variable;
<Index 2> = FindString (<text>, of, NOCASE);
<Index 1> = FindString (<text>, this, NOCASE);
<Index 2> = <Index 2> - <Index 1>;
<Result> = <[<Index 1>, <Index 2>] text>;
Message (<Result>, ON_SCREEN, NO_TIMEOUT);
<Result> has the value the content.
914
OPUS-NT Programming
System Functions
9.6.8
CallMacro
9.6.9
SaveVars
OPUS-NT Programming
915
9.7
Flow control functions are required, if a macro is not intended to run straight
from the first to the last line. Flow control function allow to include loops, conditional or unconditional jumps and jumps controlled by buttons in user dialog
boxes.
StartLoop
EndLoop
Label
Goto
If
Else
Endif
9.7.1
StartLoop
the loop count can either be a positive number, a numeric variable, or a file variable. If a FILE variable is chosen, the loop
count is determined by the number of selected files.
LoopIndex
916
OPUS-NT Programming
9.7.2
EndLoop
9.7.3
Goto
9.7.4
Label
The label name must be unique and may not be used as a variable name at the
same time. Please note, that labels within a loop are only allowed, if the Goto
statement linked to the label (or the user dialog box with the button) is placed
within the same loop.
OPUS-NT Programming
917
9.7.5
Checks a logical expression and executes the sequence of command lines following the If statement, in case the expression is TRUE. If the expression is
FALSE, the command sequence is skipped, until either the Else or Endif statement is encountered. Execution continues at the line following the Else or
Endif statement. The Endif statement is mandatory. If instructions can be
nested.
Syntax:
If (Value1 .Condition. Value2);
Command Sequence 1
.....
Else ();
Command Sequence 2
.....
Endif ();
or
If (Value1 .Condition. Value2);
Command Sequence 1
.....
Endif ();
918
Value1
Value2
.Condition.
.EQ.
.GT.
.LT.
OPUS-NT Programming
.LTEQ.
.GTEQ.
.NE.
Note that all three commands, like all other command lines, must be terminated
by semicolons. Also, the Else and Endif commands both require brackets.
The values to be compared can either be specified directly or as variables. The
keyword TIME allows to compare a time (format HH:MM:SS) statement with
the current system time. Set one of the values to the time to be compared to the
system time and use TIME as the second value.
Example 1:
If (<Number 1> .GTEQ. <Number 2>);
Message (<Number 1> is larger than or equal to <Number 2>, ON_SCREEN, NO_TIMEOUT);
Else ();
Message, (<Number 1> is smaller than <Number 2>,
ON_SCREEN, NO_TIMEOUT);
Endif ();
Example 2:
If (<Baseline?> .EQ. TRUE);
Baseline ([<File>:AB], {});
Endif ();
Example 3:
If (TIME .GT. 12:00:00);
Message (It is lunch time, ON_SCREEN, NO_TIMEOUT);
Endif ();
OPUS-NT Programming
919
Example 4:
If (...);
....
If (...);
....
Endif (...);
....
Else ();
....
If (...);
....
If (...);
....
Endif ();
....
Else ();
....
Endif ();
....
Endif ();
9.8
User interface functions are used to allow the communication between the operator and the running macro.
Message
StaticMessage
UserDialog
9.8.1
Message
920
Text
Option
OPUS-NT Programming
ON_SCREEN
ON_PRINTER
prints message.
Timeout
NO_TIMOUT
9.8.2
StaticMessage
Text n
9.8.3
HIDE
UserDialog
OPUS-NT Programming
921
Syntax:
UserDialog (Title, Options, Keyword 1:<Variable 1>,...,
Keyword 14:<Variable 14>);
Title
the text shown in the title bar of the dialog box, can be a text
or a variable.
Option
standard dialog.
NODEFAULTBUTTON
Keyword n
BLANK
empty line.
TEXT
EDIT
CHECKBOX
COMBOBOX
BUTTON
9.9
Input Functions
Input functions change variables or read parameters from a spectrum, an information block or a report.
922
OPUS-NT Programming
Input Functions
Enter Expression
FromReport Header
FromReport Matrix
GetEnumList
GetParameter
ReadTextFile
9.9.1
Enter Expression
Expression
mathematical expression.
Any mathematical expression can be used here. Values can either be represented by numbers or NUMERIC variables. Use the mathematical operators in
the same way as a pocket calculator. Use brackets to ensure the correct
sequence when calculating an equation (e.g. (2 + 2) * (4 - 2) ).
Use the following case sensitive syntax to access mathematical functions:
SQRT
PI
LN
LG
EXP
DXP
sin
cos
tan
asin
acos
atan
sinh
cosh
tanh
square root
the number Pi
natural logarithm
decimal logarithm
exponent
decimal exponent
sine
cosine
tangens
arc sine
arc cosine
arc tangens
hyperbolic sine
hyperbolic cosine
hyperbolic tangens
You can also assign text to a string variable. In this case, the expression on the
right side of the equals sign must be enclosed in single quotes. Text, variables
or a combination of both can be used.
OPUS-NT Programming
923
Example:
<DataPath> = <OPUS Path>\Data;
9.9.2
GetParameter
<File>
BlockID
Parameter
If the data block is of the type spectrum, the parameter is read from the parameter block associated with the specified data block. If the data block is of the
type INFO, one of the info text lines can be read.
The parameter names for INFO blocks are:
Txx = text definition of line xx (xx = 00 - 99)
Ixx = contents of line xx (xx = 00 - 99)
9.9.3
FromReportHeader
924
Variable 1
File
Report
Subreport
Line
OPUS-NT Programming
Input Functions
Option
9.9.4
RIGHT
FromReportMatrix
File
Report
Subreport
Line
Row
9.9.5
ReadTextFile
Reads a text file into a variable array. Each line transforms to an array element.
Syntax:
<Variable > = ReadTextFile (File);
Variable
File
9.9.6
GetEnumList
OPUS-NT Programming
925
ters, which have a predefined set of allowed values. In most cases, these values
depend on the optics type. Typically, they are chosen from a Combobox in a
user dialog.
Syntax:
<Variable> = GetEnumList (Parameter);
<Variable>
name of the array variable to receive the list of allowed values. Each array element is assigned a value.
Parameter
9.10
Output Functions
Output functions are used to print results on a printer, into a text file or into the
print log file. In the current version, only the functions TextToFile and PrintToFile are available which write lines of text into a text file. Due to compatibility reasons, the Print function of OPUS-OS/2 macros is mapped automatically
to the function PrintToFile.
TextToFile
PrintToFile
9.10.1
TextToFile
This function is the standard macro function to write a line of text into a text
file.
Syntax:
TextToFile (Path, File, Text, Option);
Path
Name
Text
Option
APPEND_TEXT
REPLACE_TEXT
926
OPUS-NT Programming
File Functions
9.10.2
PrintToFile
POP
Path
POF
Name
PTX
Text
The values of all three parameter can either be text or variables. The first command argument is normally the file list, specifying which report shall be
printed. If only a single line of text is printed, this argument is zero. Because
the Print function for reports has not been implemented so far, an argument
which does not equal zero will cause an error message.
9.11
File Functions
OPUS-NT Programming
927
9.11.1
LoadFile
name of the file variable for assigning the loaded data file.
The LoadFile function returns the internal file number of the
loaded file.
Filename
full path and file name of the file to be loaded, can either be a
text or a STRING variable or a combination of both.
Option
WARNING
ABORT
Goto (Label)
If a file could not be loaded, the error condition is TRUE and the FILE variable
is not initialized. Therefore, in general the ABORT option should be used. If
the file needs not to be processed immediately or at all, the Goto option can be
used instead. This gives you the opportunity to use the LoadFile function to
check, whether a file exists or not.
Note: This option was only introduced for reasons of compatibility with OPUSOS/2 Macro. We highly recommend to use the IT(MACROERROR, .EQ.,
TRUE); statement for error checking instead.
The LoadFile function can be used to load more than one file at the same time.
You only need to use wildcard characters (*, ?) in the file name. To process all
selected files, a StartLoop statement must follow the LoadFile command line,
which uses the name of the FILE variable as loop count.
Example:
<File> = LoadFile (D:\OPUS\DATA\SEARCH*.0, WARNING | ABORT);
StartLoop (<File>, 0);
....
EndLoop,0);
All files beginning with the name SEARCH are loaded and processed in the
loop following the LoadFile instruction.
928
OPUS-NT Programming
File Functions
If wildcards are used, then LoadFile first loads all files into OPUS and processes them in the following loop. Loading the files can become time consuming with an increasing number of files. In this case it is preferable to load the
files via the standard OPUS Load function, as shown in the following example.
Example:
<Name> = ScanPath (D:\OPUS\DATA\SEARCH*.0);
<Counter> = GetArrayCount ();
StartLoop (<Counter, 0);
[<File>:AB] = Load (0, {DAP=D:\OPUS\DATA,
DAF=<Name>
[<Index>]});
....
<Index> = <Index> + 1
Unload ([<File>:AB]);
EndLoop (0);
9.11.2
ScanPath
Scans the path for the specified files and writes each file name into an array element of the variable. Wildcard characters should be used; otherwise only a single file will be found. To process all files in a directory, use *.* as the file
name.
Syntax:
<Variable> = ScanPath (File);
<Variable>
File
9.11.3
Copy
File
Example
Copy (C:\DATA\TEST*.0, D:\DATA\TEST*.1);
OPUS-NT Programming
929
9.11.4
Rename
Renames one or more files. Files can also be moved to another directory.
Wildcard characters in the file names are allowed.
Syntax:
Rename (Source, Destination);
Source
Destination
Example
Rename (C:\DATA\TEST*.*, C:\DATA\XYZ*.*);
9.11.5
Delete
Example
Delete (C:\DATA\TEST*.*);
9.12
Time control functions can be used to control the timing within a macro. Time
intervals as well as computer system time can be used.
GetTime
Timer
9.12.1
GetTime
930
OPUS-NT Programming
Display Functions
Syntax:
GetTime (<Year>, <Month>, <Day>, <Hour>, <Minute>, <Second>);
<Year>,<Month>....
The variable type must be NUMERIC. You must use format instructions to
convert the floating-point numbers to integers. Later you can change the format
to INTEGER, using format instructions.
9.12.2
Timer
WAITTIME
WAITUNTIL
Time
Note: You can also use the IF statement to control the time behaviour within a
macro.
9.13
Display Functions
Display functions are used to show or hide spectra and to access the display limits
OpenDisplayWindow
DisplaySpectrum
UnDisplaySpectrum
GetDisplayLimits
OPUS-NT Programming
931
SetDisplayLimits
9.13.1
sets the display limits for the current macro display win
dow
OpenDisplayWindow
Opens a display window, containing all files newly created by the macro.
Commands that only modify an existing file (like Peak Pick) will not be
affected by the OpenDisplayWindow command. Changes made by these commands will be displayed in the display window, where the original data was
shown.
Syntax:
OpenDisplayWindow ();
This command requires no additional parameters. However, if used in a macro,
it should be the first command.
9.13.2
CloseDisplayWindow
9.13.3
DisplaySpectrum
BlockID
Option
NOAUTOSCALE
932
OPUS-NT Programming
Display Functions
SCALE_SELECTED
SCALE_ALL
9.13.4
UnDisplaySpectrum
Removes the specified spectrum from the display. The file remains loaded and
can be displayed again using the DisplaySpectrum command.
Syntax:
UnDisplaySpectrum ([<File>:BlockID]);
<File>
BlockID
9.13.5
GetDisplayLimits
Retrieves the current display limits of the display window created with the
OpenDisplayCommand and saves them in the functions variables. If there was
no display window created, the active window will be taken instead.
Syntax:
GetDisplayLimits (<X-Start>, <X-End>, <Y-Min>, <Y-Max>;
<X-Start>....
9.13.6
SetDisplayLimits
Sets the limits of the display window created with the OpenDisplayCommand
to the values specified. If there was no display window created the active window will be taken instead.
Syntax:
SetDisplayLimits (<X-Start>, <X-End>, <Y-Min>, <Y-Max>);
<X-Start>....
9.13.7
SetColor
OPUS-NT Programming
933
Syntax:
SetColor (<File>, <Color>);
<File>
Color
934
OPUS-NT Programming
10.1
Syntax:
CommandName (Input List 1, ..., Input List n, {PAR 1=Value 1, ..., PAR
n=Value n});
CommandName
Input List n
PAR n
Value n
BlockID n
Note that the files in a list are separated by blanks, while the lists themselves are
separated by commas. Most functions require only one file list; a few files however, (like Make Compatible or Subtraction) need several file lists.
10.2
We strongly recommend to only use the Macro Editor, if you want to include
OPUS commands into macros. Using the Macro Editor guarantees that all relevant parameters required by the command are inlcuded in the command line and
PARAMETER section. Furthermore, it is ensured that these parameters are initialized with valid values.
OPUS-NT Programming
101
To append an OPUS command to a macro, simply select the command from the
OPUS pull-down menu, while the Macro Editor is running. Choose the appropropriate parameters, files and settings as usual in the dialog box of the command.
After clicking on the Execution button in the dialog box for executing the command, the OPUS command dialog box is replaced by a parameter dialog, that
lists all parameters relevant for the processing function. When you click the OK
button, the respective OPUS processing function will be appended to the macro.
102
OPUS-NT Programming
Column 1:
Column 2:
Parameter name
Column 3:
Column 4:
OPUS-NT Programming
103
10.3
Measurement Commands
As already mentioned, the measurement commands differ from the rest of the
OPUS commands. When you include the Measurement command in a macro,
you will find that only two parameters XPP and EXP are selected by default.
XPP represents the directory of the experiment file and EXP the name of the
experiment. It is highly recommended to assign macro variables to these
parameters. This guarantees, that a measurement started from a macro always
uses an existing experiment file (and therefore a defined parameter set). For
measurement functions, the remaining parameters wont be included in the
PARAMETER section!
Other parameters than XPP and EXP should only be selected, if they are
intended to replace values stored in the experiment file or if macro variables
should be assigned to these parameters. This will become clear, if one looks at
the sequence in which a measurement command is executed.
Regardless of the original settings the measurement will now run 16 scans.
104
OPUS-NT Programming
Reference Section
Regardless of the settings stored in the experiment file, the measurement will
now run 16 scans.
10.4
Reference Section
The following section describes the OPUS commands in detail. The sections
are all structured in the same way. You will find:
the title, which consists of the OPUS command referenced in this
section.
a summary of the command.
an indication, whether the command modifies files or not.
an explanation of the syntax.
a table, listing all command parameters and their function.
a note, if the command has not been implemented in OPUS to this
point in time.
All of the parameters you will find listed in the tables are required, and must be
stated as a part of the command. A parameter statement should therefore be
included either in the parameter list of the command or in the PARAMETER
section of the macro. If no parameter statement was made in a macro, OPUS
will use the parameters of the active parameter set, when executing the macro.
This usually leads to unpredictable results.
10.5
A
ABTR
Average
B
Baseline
BlackBody
C
ChangeDataBlockType
Convert
CopyDataBlock
Cut
OPUS-NT Programming
105
D
Deconvolution
DeleteDataBlock
Derivative
E
ExternalProgram
Extrapolation
F
FFT
FreqCalibration
I
InfoInput
Integrate
InverseFT
J
JCAMPToOPUS
K
KramersKronig
M
MakeCompatible
MeasureReference
Merge
N
Normalize
normalizes a spectrum
P
PeakPick
Plot
PostFTZerofill
R
RamanCorrection
Restore
106
OPUS-NT Programming
S
Save
SendFile
SignalToNoise
Smooth
StraightLine
Subtract
U
Unload
10.6
Manipulation Functions
ABTR
Average
Baseline
BlackBody
Convert
Cut
Deconvolution
Derivative
Extrapolation
FFT
FreqCalibration
InverseFT
KramersKronig
MakeCompatible
Merge
Normalize
PostFTZerofill
RamanCorrection
Smooth
StraightLine
Subtract
Evaluation Functions
Integrate
PeakPick
SignalToNoise
integrates a spectrum
creates a peak table
calculates the Signal-to-Noise ratio
OPUS-NT Programming
107
File Functions
ChangeDataBlockType
CopyDataBlock
DeleteDataBlock
Restore
Save
SendFile
Unload
Measurement Functions
MeasureReference
SendCommand
SaveReference
LoadReference
Library Functions
LibrarySearchInfo
LibrarySearchPeak
LibrarySearchStructure
LibrarySearchSpectrum
LibraryInitialize
LibraryStore
LibraryEdit
InfoInput
Miscellaneous Functions
ExternalProgram
Plot
10.7
10.7.1
108
OPUS-NT Programming
Value
Description
CCM
automatic
AB TR
TR AB
10.7.2
Average
Averages spectra.
This command requires three file lists:
File List 1:
Spectra to be averaged.
File List 2:
File List 3:
Value
Description
QA0
NO
YES
NO
YES
LIS
FIL
QAM
Text
QAN
Text
QAO
Numerisch
QFB
Text
QFC
Text
QA2
QAE
QAF
QAL
OPUS-NT Programming
109
10.7.3
Baseline
Value
Description
BME
Scattering correction
BPO
10 ... 200
BCO
10.7.4
BlackBody
Value
Description
QTE
pos. number
QPM
energy
photons
10.7.5
Convert
Converts spectra.
This functions modifies the selected spectrum and changes the data block type
accordingly.
Convert ([<File>:BlockID] ...., {...});
1010
OPUS-NT Programming
Parameter
Value
Description
CSD
KM Refl
AB, TR ATR
ATR AB
Refl lgRefl
lgRefl Refl
ScSm Raman
Raman ScSm
10.7.6
Cut
Value
Description
CFX
number
X-start frequency
CLX
number
X-end frequency
10.7.7
Deconvolution
Value
DSP
Description
peak form
LO
Lorentzian
GA
Gaussian
DEF
pos. number
deconvolution factor
DNR
pos. number
DES
number
X-start frequency
DEE
number
X-end frequency
DWR
frequency limits
file limits
OPUS-NT Programming
1011
10.7.8
Derivative
Value
Description
QSP
5, 9, 13,
17, 21, 25
QOD
1...5
order of derivative
10.7.9
Extrapolation
Extrapolates a spectrum.
This functions modifies the selected spectrum.
Extrapolation ([<File>:BlockID] ...., {...});
Parameter
Value
Function
QX0
number
extrapolate to zero
QX1
number
extrapolate to infinity
QX2
number
QX3
number
QX4
number
10.7.10 FFT
Performs a Fast Fourier transformation..
This command performs a fast Fourier transformation of an interferogram. The
result is a single channel spectrum data block, which will be added to the file.
FFT ([<File>:BlockID] ...., {...});
1012
OPUS-NT Programming
Parameter
Value
Description
FTS
number
FTE
number
FZF
pos. number
Zerofilling factor
FTR
pos. number
resolution
FHR
pos. number
phase resolution
bit code used to indicate forward/backward or
even/odd
FBW
1
forward interferogram
backward interferogram
even separation
16
odd separation
FTA
FLR
apodization function
BX
Boxcar
TR
Triangular
4P
Four Point
HG
Happ-Genzel
B3
Blackman-Harris 3-term
B4
Blackman-Harris 4-term
NBW
Norton-Beer, weak
NBM
Norton-Beer, medium
NBS
Norton-Beer, strong
pos. number
limit resolution
FHZ
phase correction
ML
Mertz
SM
Signed Mertz
PW
Power spectrum
MS
NO
FZF
pos. number
Zerofilling factor
FNL
no nonlinearity correction
nonlinearity correction
FNC
pos. number
FNE
pos. number
FSM
OPUS-NT Programming
1013
MN
minimum
MX
maximum
MI
NO
MA
manual input
FPP
pos. number
peak position
FSR
pos. number
search range
FSY
symmetrical
antisymmetrical
automatic
FTT
absorbance
interferogram
single channel
power spectrum
16
phase spectrum
64
128
10.7.11 FreqCalibration
Performs a frequency calibration.
This functions modifies the selected spectrum.
FreqCalibration ([<File>:BlockID] ...., {...});
Parameter
Value
Description
QF0
NO
YES
MWC
number
factor
AWC
number
offset
10.7.12 InverseFT
Performs an inverse Fourier transformation.
This command performs an inverse Fourier transformation of a spectrum. The
result is a single channel spectrum data block, which will be added to the file.
1014
OPUS-NT Programming
Value
RSY
Description
symmetry
symmetric
Antisymmetric
RXS
number
X-start frequency
RXE
number
X-end frequency
RWR
10.7.13 KramersKronig
Performs a Kramers Kronig transformation.
This command performs a Kramers-Kronig transformation of a reflectance
spectrum. The real and imaginary part of an absorbance-like spectrum will be
calculated. The result is a single channel spectrum data block which will be
added to the file.
KramersKronig ([<File>:BlockID] ...., {...});
Parameter
Value
KKR
Description
desired result
absorbance
phase
KKS
number
X-start frequency
KKE
number
X-end frequency
KWR
10.7.14 MakeCompatible
Makes spectra compatible.
This functions interpolates the selected spectrum to the frequency limits and
point raster of a reference spectrum.
This functions modifies the selected spectrum and changes the data block type
accordingly. The reference spectrum remains unchanged.
OPUS-NT Programming
1015
reference file.
<File2>
file to be interpolated.
Parameter
Value
Description
CME
interpolation method
2
interpolation
reduce resolution
10.7.15 Merge
This function has not been implemented yet.
Merges spectra.
Merge ([<File>:BlockID] ...., {...});
10.7.16 Normalize
Normalizes a spectrum.
This functions modifies the selected spectrum.
Normalize ([<File>:BlockID] ...., {...});
Parameter
Value
Description
NME
min-max normalization
vector normalization
offset correction
NFX
number
X-start frequency
NLX
number
X-end frequency
NWR
10.7.17 PostFTZerofill
Performs a post Zerofilling of a spectrum.
This functions modifies the selected spectrum.
1016
OPUS-NT Programming
Value
Description
PZF
pos. number
Zerofilling Factor
PZS
number
X-start frequency
PZE
number
X-end frequency
PWR
frequency limits
0
10.7.18 RamanCorrection
Performs a Raman correction.
This functions modifies the selected spectrum.
RamanCorrection ([<File>:BlockID] ...., {...});
Parameter
Value
QC0
Description
background correction
perform correction
QC1
scatter correction
0
perform correction
QC2
perform correction
QC3
Text
QC4
Text
QC5
pos. number
reference temperature
10.7.19 Smooth
Smoothes a spectrum.
This functions modifies the selected spectrum.
OPUS-NT Programming
1017
Value
Description
QSP
5, 9, 13,
17, 21, 25
10.7.20 StraightLine
Generates a straight line.
This functions modifies the selected spectrum.
StraightLine ([<File>:BlockID] ...., {...});
Parameter
Value
Description
GFX
number
X-start frequency
GLX
number
X-end frequency
10.7.21 Subtract
Subtracts one or more spectra from another spectrum.
The spectrum from which the others are subtracted is modified. The spectrum/
spectra which are subtracted stay unchanged.
Subtract ([<File A>:BlockIDA], ([<File B>:BlockIDB] ...., {...});
<File A>
<File B>
Parameter
Value
SUB
1018
Description
subtraction mode
interactive
autosubtraction
SUN
number of spectra
SX1
X-start frequency
SX2
X-end frequency
OPUS-NT Programming
10.8
10.8.1
Integrates a spectrum.
This function adds an integration report to the file.
Integrate ([<File>:BlockID] ...., {...});
Parameter
Value
Description
LPT
text
LFN
text
LRM
10.8.2
report mode
0
PeakPick
Value
PSM
NSP
Description
peak mode
2. derivative
5, 9, 13,
17, 21, 25
WHR
frequency limits
0
LXP
number
start frequency
FXP
number
end frequency
PPM
peak definition
1
find maximum
OPUS-NT Programming
1019
PTR
find minimum
pos. number
QP0
decimals
QP3
YES
NO
pos. integer
QP4
QP5
YES
NO
pos. integer
QP6
QP7
YES
NO
pos. integer
QP8
10.8.3
NO
SignalToNoise
Value
Description
NF1
number
start frequency
NF2
number
end frequency
SN1
number
S/N (RMS)
SN2
number
SN3
number
SN4
number
SNF
1020
flags
OPUS-NT Programming
10.9
10.9.1
10.9.2
CopyDataBlock
source file.
blockID
<file B>
destination file.
10.9.3
DeleteDataBlock
10.9.4
Restore
OPUS-NT Programming
1021
Value
OEX
Description
overwrite mode
overwrite file
SAN
file name
DAP
target directory
COF
move file
16
remove copies
32
64
128
256
512
1024
The following parameters will only be used when saving a file as an x,y table.
DPA
pos. number
DPO
pos. number
SEP
character
separator
YON
Y-values
1
Y-Values only
X and Y-Values
ADP
1022
data points
1
OPUS-NT Programming
10.9.6
SendFile
Value
Description
COF
10.9.7
data blocks
0
Unload
OPUS-NT Programming
1023
Value
Description
SNM
text
sample name
SFM
text
sample preparation
CNM
text
operator
XPM
text
XPP
text
RES
pos. number
resolution
NSS
pos. number
number of scans
10.10.2 SendCommand
Sends an optics command to the optics bench.
This function does not need an input spectrum.
SendFile (0, {...});
Parameter
Value
Description
UNI
text
text to be sent
10.10.3 SaveReference
Saves a reference spectrum from the AQP to disk.
This function creates a new file.
SaveReference (0, {...});
The function does not require any parameters.
10.10.4 LoadReference
Loads a reference spectrum from disk into the AQP.
This function does not modify the spectrum.
LoadReference ([<File>:ScRf], {...});
The function does not require any parameters.
1024
OPUS-NT Programming
10.11
10.11.1 LibrarySearchInfo
Searches for information in a spectrum library.
This function performs a query for information within a spectrum library. The
query text must be supplied in a query file (extension .INL); use the OPUS-NT
Information Search dialog to create and save a query file.
[<File1>:BlockID] = LibrarySearchInfo (0, {...});
Standard search.
<File 1>
<File 2>
Parameter
Value
Description
Remarks
SIH
NUMERIC
maximum number
of hits
must be > 0
SIN
STRING
SIP
STRING
LB1
STRING
10.11.2 LibrarySearchPeak
Searches for peaks in a spectrum library.
This function performs a query for peaks within a spectrum library. The query
R must be supplied in a query file (extension .PKL); use the OPUS-NT Peak
Search dialog to create and save such a query file.
OPUS-NT Programming
1025
<File 2>
Parameter
Description
Remarks
SPQ
NUMERIC
SPH
NUMERIC
must be > 0
SPA
NUMERIC
search algorithm
512
hit if one
matches
1024
hit if
match
2048
4096
count
peaks
PNP
STRING
PPP
STRING
LB1
1026
Value
STRING
all
peak
peaks
matching
OPUS-NT Programming
10.11.3 LibrarySearchStructure
Searches for chemical structures in a spectrum library.
This function performs a query for chemical structures within a library file. The
query must be supplied in a structure data block.
LibrarySendStructure([<File1>:BlockID], 0, {...});
Standard search.
<File 1>
<File 2>
Parameter
Value
Description
Remarks
STH
NUMERIC
maximum number
of Hits
must be > 0
LAL
NUMERIC
search algorithm
8192
match exact
12288
match embedded
LB1
STRING
10.11.4 LibrarySearchSpectrum
Searches for spectra in a spectrum library.
This function performs a query for peaks within a spectrum library. The query
spectrum must be absorbance-like.
LibrarySearchSpectrum ([<File1>:BlockID], 0, {...});
Standard search.
<File 1>
OPUS-NT Programming
1027
<File 2>
Parameter
Description
Remarks
LSS
NUMERIC
sensitivity
SSQ
NUMERIC
SSH
NUMERIC
maximum number
of Hits
must be > 0
NUMERIC
search algorithm
standard
spectrum
tion
SS1
LB1
1028
Value
correla-
+16
no derivative
+32
first derivative
+64
second derivative
+128
vector
tion
+256
min-max
ization
STRING
normaliza-
normal-
OPUS-NT Programming
10.11.5 LibraryInitialize
Creates a new, empty library.
A method file (extension .MTD) and a text file (extension .TXD) is needed to
create a library file.
LibraryInitialize ({...});
The function does not require any parameters.
Parameter
Value
Description
Remarks
LPT
STRING
LBT
STRING
MTP
STRING
LMT
STRING
LBP
STRING
LBN
STRING
LID
STRING
library description
maximum 79 characters
LCP
STRING
copyright
maximum 79 characters
10.11.6 LibraryStore
Stores a new entry, the library description, and the definition of information
saved in a library file.
LibraryStore (0, [<File>:BlockID], {...});
The function does not require an input file list.
OPUS-NT Programming
1029
Parameter
Value
Description
Remarks
LSM
NUMERIC
storage mode
new entry
replace entry
replace info
insert/replace structure
LBP
STRING
directory of
library file
LBN
STRING
LBS
NUMERIC
entry number
the
10.11.7 LibraryEdit
This function loads and deletes entries of a library. Furthermore, the description of the library as well as the description of the stored information can als be
edited.
[<File>:BlockID] = LibraryEdit (0, {...});
Syntax to load a spectrum of a library entry.
LibraryEdit (0, {...});
Syntax for any other option
1030
OPUS-NT Programming
.
Parameter
Value
Description
LMO
NUMERIC
edit mode
load entry
delete entry
13
change information
set
14
change description
LBS
NUMERIC
entry number
LBP
STRING
directory of
library file
LBN
STRING
new
information
definintion file or
library description
LID
STRING
Remarks
10.11.8 InfoInput
Allows information input.
This function adds an information block to the selected file. Depending on the
mode, either the complete info block is replaced, only selected information of
an existing info block is replaced, or a new file with an info block will be created.
InfoInput ([<File>:BlockID] ...., {...});
Syntax if a block should be replaced or extended.
[<File>:BlockID] = InfoInput ({...});
Syntax if a new file should be created.
OPUS-NT Programming
1031
Parameter
Value
Description
IRM
STRING
information
mode
INP
STRING
INM
STRING
I01
STRING
information of line 1
I02
STRING
information of line 2
I99
STRING
information of line
99
T01
STRING
description of line 1
T02
STRING
description of line 2
STRING
description of line
99
input
...
...
T99
1032
OPUS-NT Programming
Value
XPF
Description
start as OPUS task
XST
XPR
Text
XPA
Text
parameteres to be exchanged
XWI
extra VDM
XWS
normal
maximized
minimized
hidden
XCW
OPUS-NT Programming
1033
XSB
XEM
XDM
XVP
XPM
<C/S>
DDE
transaction type
Bit 0 gelscht
poke
execute
request
DDS
Text
DDT
Text
DDE topic
DDI
Text
DDE item
DDD
Text
10.12.2 ParameterEditor
Changes the sample parameters.
This function changes the following parameters:
sample name
sample form
user name
sample number
Note that the statement of all values is required when executing this function.
In addition, the axes labels and scaling factors used for the axes can be entered.
ParameterEditor ([<File>:BlockID] ...., {...});
1034
OPUS-NT Programming
Parameter
Value
Description
CNM
Text
user name
SNM
Text
sample nname
SFM
Text
sample form
RSN
Zahl
sample number
XTX
Text
X-axis label
YTX
Text
Y-axis label
ZTX
Text
Z-axis label
XAF
Number
YAF
Number
ZAF
Number
10.12.3 Plot
Plots spectra.
This function does not change the spectrum.
Plot ([<File>:BlockID] ...., {...});;
Parameter
Value
PDV
Description
output device
Printer
printer
Clipboard
clipboard
SCP
Text
SCN
Text
PUN
POP
Text
POF
Text
PDH
PL2
Number
PPA
Text
PPA starts with FRM=n and defines how many frame parameters follow. For
each frame the following parameters (separated by commas) are necessary:
OPUS-NT Programming
1035
Parameter
Value
Description
NPL
Number
XSP
Number
X start frequency
XEP
Number
X end frequency
YMN
Number
YMX
Number
ASE
YES/NO
CWN
YES/NO
COL
Numbers
10.12.4 VBScript
Starts a VisualBasic script
This function loads and then runs a VisualBasic script. Parameters and data
blocks can be forwarded to the script
VBScript ([<File>:BlockID] ...., {...});
Parameter
Value
Description
VBS
Text
VBP
Text
VBW
VBH
1036
OPUS-NT Programming
Sample Parameters
The sample parameters stored with the spectrum:
SNM
SFM
CNM
HIS
PTH
EXP
PAT
NAM
NA2
ATX
XPP
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
Sample Name
Sample Form
Operator Name
History of Last Operation
Measurement Path
Experiment
Path of File
Filename
Ch. 2 Filename
Annotation text
Experiment Path
Standard Parameters
DPF
NPT
FXV
LXV
(numerical)
(numerical)
(numerical)
(numerical)
OPUS-NT Programming
111
CSF
MXY
MNY
DXU
DYU
DAT
TIM
(numerical)
(numerical)
(numerical)
(list of values)
WN =
MI =
NM =
LGW =
MIN =
SEC =
PNT =
EV =
MM =
CM =
MIS =
MUS =
(list of values)
SC =
TR =
AB =
KM =
LA =
DR =
ABS =
REF =
TRA =
RRK =
IRK =
RTK =
ITK =
DF1 =
DF2 =
(text)
(text)
Y - Scaling Factor
Y - Maximum
Y - Minimum
X Units
Wavenumber cm-1
Micron
Nanometers
Log Wavenumber
Minutes
Seconds
Points
eV
Millimeters
Centimeters
msec
sec
Y Units
Single channel
Transmittance [%]
Absorbance Units
Kubelka Munck
Log Absorbance
Diffuse Reflectance
Absorbance
Reflectance
Transmittance
Re (Amplitude Reflectivity Coefficient)
Im (Amplitude Reflectivity Coefficient)
Re (Amplitude Transmission Coefficient)
Im (Amplitude Transmission Coefficient)
Re ( Dielectric Function )
Im ( Dielectric Function )
Date of Measurement
Time of Measurement
User-Defined Labels
XTX
YTX
ZTX
XAF
YAF
ZAF
(text)
(text)
(text)
(numerical)
(numerical)
(numerical)
X - axis Label
Y - axis Label
Z axis Label
X axis factor
Y axis factor
Z axis factor
Derivatives, Smoothing
DER
QS1
SMO
QS0
112
(numerical)
(text)
(numerical)
(text)
Derivative
Derivative
Smoothing points for der.
Smoothing points
OPUS-NT Programming
3D Files
GSQ
AOX
AOY
DDX
DDY
NPX
NPY
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
GS Base Quality
Map Origin X
Map Origin Y
Map Delta X
Map Delta Y
Map Points in X
Map Points in Y
S/N Ratio
NF1
NF2
SN1
SN2
SN3
SN4
SNF
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
Frequency Calibration
MWC
AWC
(numerical)
(numerical)
(numerical)
(text)
Hit Quality
Compound Name
Instrument Parameters
Parameters used for the spectrometer settings that are stored together with a
spectrum:
DPH
MOF
NLA
NLB
HFL
LFL
DFR
DFC
HFF
LFF
ASG
ARG
ALF
AHF
ASS
ARS
GFW
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
OPUS-NT Programming
113
GBW
BFW
BBW
DUR
RSN
PKA
PKL
PRA
PRL
SSM
SSP
SGP
SGW
INS
ITF
SIM
DEB
LOG
ADR
AD2
RMX
PLL
FFT
MXD
FOC
ABP
LWN
RLW
RLP
RDY
RC0
RC1
SRT
ERT
MAX
MAY
AN1
AN2
(numerical)
Number of Good BW Scans
(numerical)
Number of Bad FW Scans
(numerical)
Number of Bad BW Scans
(numerical)
Scan time (sec)
(numerical)
Running Sample Number
(numerical)
Peak Amplitude
(numerical)
Peak Location
(numerical)
Backward Peak Amplitude
(numerical)
Backward Peak Location
(numerical)
Sample Spacing Multiplicator
(numerical)
Sample Spacing Divisor
(numerical)
Switch Gain Position
(numerical)
Gain Switch Window
(text)
Instrument Type
(list of values)
Interface Type for Optic
0 = 25/48
1 = 22/28/55/66/88/120/100
2 = 85/110/113
(numerical)
Simulation Mode
(numerical)
Debug Printer Mode
(numerical)
Logfile for Measurement
(numerical)
AQP Adress
(numerical)
AQP2 Adress
(numerical)
Resolution Limit
(numerical)
Maximum PLL Setting
(numerical)
Maximum FT Size in Ks
(numerical)
Maximum ADC Sate in Hz
(numerical)
Focal Length
(numerical)
Absolute Peak Pos in Laser*2
(numerical)
Laser Wavenumber
(numerical)
Raman Laser Wavenumber
(numerical)
Raman Laser Power in mW
(list of values)
Ready Check
0 = OFF
1 = ON
(list of values)
Raman Background Corrected
NO = No
YES = Yes
(list of values)
Raman Scattering Corrected
NO = No
YES = Yes
(numerical)
Start time (sec)
(numerical)
End time (sec)
(numerical)
X Measurement Position
(numerical)
Y Measurement Position
(numerical)
Analog Signal 1
(numerical)
Analog Signal 2
114
OPUS-NT Programming
CH2
SGN
SG2
RGN
RG2
GSW
GSG
AQM
(list of values)
Channel 2
0 = OFF
1 = ON
(list of values)
Signal Gain, Sample
-1 = Automatic
0=1
1=2
2=4
3=8
4 = 16
5 = 32
6 = 64
7 = 128
(list of values)
Signal Gain, Sample
-1 = Automatic
0=1
1=2
2=4
3=8
4 = 16
5 = 32
6 = 64
7 = 128
(list of values)
Signal Gain, Background
-1 = Automatic
0=1
1=2
2=4
3=8
4 = 16
5 = 32
6 = 64
7 = 128
(list of values)
Signal Gain, Background
-1 = Automatic
0=1
1=2
2=4
3=8
4 = 16
5 = 32
6 = 64
7 = 128
(numerical)
Gain Switch Window
(list of values)
Gain Switch Gain
1 = OFF
8 = ON
(list of values)
Acquisition Mode
SN = Single Sided
DN = Double Sided
SF = Single Sided Fast Return
SD = Single Sided, Forward-Backward
DD = Double Sided, Forward-Backward
DF = Double Sided, Fast Return
OPUS-NT Programming
115
NSS
NSR
REP
DLR
MIN
MIR
SOS
SOT
STR
COR
DLY
DEL
HFW
LFW
RES
RE2
TDL
PLF
SPO
RPO
WAR
116
(numerical)
Sample Scans
(numerical)
Background Scans
(numerical)
Repeat Count
(numerical)
Delay Between Repeats in Sec.
(numerical)
Sample Meas. Duration in Min.
(numerical)
Background Meas. Duration in Min.
(numerical)
Scantime or Scans
(list of values)
Sample Scans or Time
0 = Scans
1 = Minutes
(list of values)
BG Scans or Time
0 = Scans
1 = Minutes
(list of values)
Correlation Test Mode
NO = No
LO = Around Peak,Low
HI = Around Peak,High
FUL = Full Igram length
(numerical)
Stabilization Delay
(numerical)
Delay Before Measurement
(numerical)
Wanted High Frequency Limit
(numerical)
Wanted Low Frequency Limit
(numerical)
Resolution
(numerical)
Resolution Ch.2
(numerical)
To do list
(list of values)
Result Spectrum
TR = Transmittance
AB = Absorbance
KM = Kubelka Munk
RAM = Raman Spectrum
EMI = Emission
RFL = Reflectance
LRF = Log Reflectance
ATR = ATR Spectrum
PAS = PAS Spectrum
(list of values)
Sample Number
0 = Background Position
1=1
2=2
.........
63 = 63
(list of values)
Background Number
0 = Background Position
1=1
2=2
.....
63 = 63
(list of values)
Tr. Rec. Resolution
4 ns
5 ns
8 ns
10 ns
20 ns
24 ns
OPUS-NT Programming
WAS
WRC
WTD
WPD
WXP
WSS
W2W
WXD
WDV
WIR
25 ns
33 ns
40 ns
50 ns
100 ns
200 ns
250 ns
400 ns
500 ns
1 s
2 s
2.5 s
4 s
5 s
10 s
25 s
40 s
50 s
100 s
(numerical)
Tr. Rec. Slices
(numerical)
Tr. Rec. Repeat Count
(numerical)
Tr. Rec. trigger Delay in points
(numerical)
Tr. Rec. Stab. Delay after Stepping
(list of values)
Tr. Rec. Trigger Mode
1 = Internal
2 = External Positive Edge
3 = External Negative Edge
(list of values)
Tr. Rec. Sampling Source
0 = External
1 = Linear Timescale
2 = Compress to Log. Timescale
(list of values)
Tr. Rec. Channel 2 Weighting
0 = Unused
1 = Use for Phase Correction
2 = Use for Weighting
3 = Use for Weighting, discard if < Threshold
4 = Discard Experiment if < Threshold
(numerical)
Tr. Rec. Experiment Delay
(list of values)
Transient Recorder
1 = PAD82A
2 = PAD82B
3 = PAD82
4 = PAD1232a
5 = PAD1232b
6 = PAD1232c
(list of values)
Tr. Rec. Input Range
1 = 200mV
2 = 500mV
3 = 1V
4 = 2V
5 = 4V
6 = 0..400mV
7 = 0..1V
8 = 0..2V
OPUS-NT Programming
117
WTH
TRR
TRS
TRC
TRD
TRP
TRM
TRX
ITS
ISP
IDL
ITR
STD
STC
SMX
SMD
4=OLD
SMA
SMF
AMF
ADA
PDA
CIN
CIM
CDT
CDS
CTM
CSV
CTL
GSS
GSO
GSP
CLD
CMD
MLS
MPO
MSH
NDV
NOX
NOY
NSX
NSY
NGX
NGY
MEX
MUN
MPX
MPY
118
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
2=MOD-DEMOD
PHASE 8=AMPL )
(numerical)
Scanner Modulation Amplitude
(numerical)
Scanner Modulation Frequency
(numerical)
Ampl. Modulation Frequency
(numerical)
Ampl. Demodulation Angle
(numerical)
Phase Demodulation Angle
(numerical)
Chrom Integrate Trace
(text)
Chrom Integration Method
(numerical)
Chrom Display Trace
(numerical)
Chrom Display Spectrum
(numerical)
Chrom Start Trigger Mode
(numerical)
Chrom Save Mode
(numerical)
Chrom Trigger Level
(numerical)
Gram Schmidt Size
(numerical)
Gram Schmidt Offset
(numerical)
Gram Schmidt Points
(numerical)
Limit Run Duration
(numerical)
Max Run Duration
(text)
Map XY List
(numerical)
Map Port (com 1...n)
(numerical)
Map Shape (1..6)
(list of values)
Map Device
0 = Internal (MCLStage)
1 = Microscope (MCLStage)
(numerical)
Map Origin X
(numerical)
Map Origin Y
(numerical)
Map Spacing X
(numerical)
Map Spacing Y
(numerical)
Map Gram Schmidt X Base
(numerical)
Map Gram Schmidt Y Base
(text)
Map Measurement Experiment
(list of values)
Map units
0 = Micron
1 = mm
2 = cm
(numerical)
Map # Pos X
(numerical)
Map # Pos Y
OPUS-NT Programming
MSS
MCI
MIM
MCM
MEM
MSV
MVM
MRL
MGT
MGS
MGO
MGP
MXS
MXE
MYS
MYE
MDM
MDP
XS2
XE2
YS2
YE2
(numerical)
(numerical)
(text)
(numerical)
(text)
(numerical)
(text)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
FT-Parameters
Parameters used for the Fourier Transformation, that are stored together with a
spectrum:
AF2
HQ2
LQ2
PH2
SP2
ZF2
(list of values)
Apodization Function
BX = Boxcar
TR = Triangular
4P = Four Point
HG = Happ-Genzel
B3 = Blackman-Harris 3-term
B4 = Blackman-Harris 4-term
NBW = Norton-Beer, Weak
NBM = Norton-Beer, Medium
NBS = Norton-Beer, Strong
US1 = User One
US2 = User Two
(numerical)
End Frequency Limit for File
(numerical)
Start Frequency Limit for File
(list of values)
Phase Correction Mode
ML = Mertz
SM = Mertz Signed
PW = Power Spectrum
MLP = Mertz / No Peak Search
SMP = Mertz Signed / No Peak Search
PWP = Power / No Peak Search
(list of values)
Stored Phase Mode
NO = No
(list of values)
Zero Filling Factor
1=1
OPUS-NT Programming
119
APF
HFQ
LFQ
PHZ
PHR
NLI
NL2
DIG
DI2
SPZ
ZFF
1110
2=2
4=4
8=8
16 = 16
32 = 32
64 = 64
128 = 128
256 = 256
512 = 512
(list of values)
Apodization Function
BX = Boxcar
TR = Triangular
4P = Four point
HG = Happ-Genzel
B3 = Blackman-Harris 3-Term
B4 = Blackman-Harris 4-Term
NBW = Norton-Beer, Weak
NBM = Norton-Beer, Medium
NBS = Norton-Beer, Strong
US1 = User One
US2 = User Two
(numerical)
End Frequency Limit for File
(numerical)
Start Frequency Limit for File
(list of values)
Phase Correction Mode
ML = Mertz
SM = Mertz Signed
PW = Power Spectrum
MLP = Mertz / No Peak Search
SMP = Mertz Signed / No Peak Search
PWP = Power / No Peak Search
MS = Mertz / Stored Phase
NO = No / Save Complex Data
(numerical)
Phase Resolution
(numerical)
Non Linearity Correction
(numerical)
Non Linearity Correction
(numerical)
Digital Filter
(numerical)
Digital Filter
(list of values)
Stored Phase Mode
NO = No
(list of values)
Zero Filling Factor
1=1
2=2
4=4
8=8
16 = 16
32 = 32
64 = 64
128 = 128
256 = 256
512 = 512
OPUS-NT Programming
ADC
SON
SRC
VSC
VEL
HPF
LPF
SRL
RFL
POL
(numerical)
(text)
(list of values)
(list of values)
(list of values)
(list of values)
(list of values)
(list of values)
(list of values)
(list of values)
(list of values)
(list of values)
1= ADC 1
2 = ADC 2
3 = ON
(list of values)
0 = OFF
1=1
2=2
3=1&2
(list of values)
0 = OFF
1 = ON
2 = Extended
(list of values)
(numerical)
(list of values)
(list of values)
(list of values)
(numerical)
(numerical)
(list of values)
91 = Out
0 = 0
90 = 90
External Synchronisation
General
FIM
(numerical)
S/N Ratio
NF1
(numerical)
OPUS-NT Programming
1111
NF2
SN1
SN2
SN3
SN4
SNF
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
Subtract
SX1
SX2
SUN
SUB
Assemble GC
QA6
QA7
QA8
QA9
QAA
QAB
QAC
QAD
LST
BLK
QM0
QM1
QM2
QM3
QM4
(text)
Assembled GC Spectrum Path
(text)
Assembled GC Spectrum
(numerical)
Assembled GC Start Frequency
(numerical)
Assembled GC End Frequency
(numerical)
Assembled GC Whole x-Range
(list of values)
Assembled GC Z Units
SEC = Seconds
MIN = Minutes
NM = Nanometers
MI = Micrometers
MM = Millimeters
CM = Centimeters
WN = Wavenumber 1/cm
LGW = Log Wavenumber
EV = eV
PNT = Points
MIS = msec
MUS = sec
NON = None
(numerical)
Assembled GC Z-Start
(numerical)
Assembled GC Z-End
(text)
List of Filenames
(text)
Blocktype to Assemble
(list of values)
Assembled Map Units
MI = Micrometers
MM = Millimeters
CM = Centimeters
PNT = Points
(numerical)
Assembled Map x points
(numerical)
Assembled Map Delta x
(numerical)
Assembled Map y points
(numerical)
Assembled Map Delta y
Conformity Test
QCF
QCG
CSM
1112
(text)
(text)
(text)
Post-FT ZFF
PZF
PZS
PZE
PWR
(numerical)
(numerical)
(numerical)
(numerical)
Fourier Transformation
FHZ
FTA
FZF
FTS
FTE
FTR
FHR
FLR
FTT
FBW
FNL
FNC
FNE
FSM
(list of values)
FT Phase Correction Mode
ML = Mertz
SM = Mertz Signed
PW = Power Spectrum
MS = Mertz / Stored Phase
NO = No / Save Complex Data
FM = Forman
FS = Forman / Stored Phase
FP = Forman / Preapodized
DP = Doubled Phase
(list of values)
FT Apodization Function
BX = Boxcar
TR = Triangular
4P = Four point
HG = Happ-Genzel
B3 = Blackman-Harris 3-Term
B4 = Blackman-Harris 4-Term
NBW = Norton-Beer, Weak
NBM = Norton-Beer, Medium
NBS = Norton-Beer, Strong
US1 = User One
US2 =User Two
(list of values)
FT Zero Filling Factor
1=1
2=2
4=4
8=8
16 = 16
32 = 32
64 = 64
128 = 128
256 = 256
512 = 512
(numerical)
FT Start Frequency
(numerical)
FT End Freqency
(numerical)
FT Resolution Limit
(numerical)
FT Phase Resolution
(numerical)
FT Limit Resolution
(numerical)
FT to do list
(numerical)
Forward/Backward Igram
(numerical)
Non Linearity Correction
(numerical)
FT Detector Cutoff Freq.
(numerical)
FT Modulation Efficiency
(list of values)
FT ZPD Search Mode
OPUS-NT Programming
1113
FPP
FSR
FSY
Kramers-Kronig Transformation
KKS
KKE
KWR
KMT
KKR
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
Deconvolution
DEF
DNR
DES
DEE
DWR
DSP
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(list of values)
LO = Lorentz
GA = Gauss
Deconvolution Factor
Deconv Noise Reduction
Deconv Start Frequency
Deconv End Frequency
Deconv Whole Range
Deconv Line Shape
Curve Fitting
FXS
FXE
FWR
(numerical)
(numerical)
(numerical)
Inverse FT
RXS
RXE
RWR
RSY
(numerical)
(numerical)
(numerical)
(numerical)
Symmetric FT
FPS
LPS
WRS
SSY
1114
(numerical)
(numerical)
(numerical)
(numerical)
OPUS-NT Programming
2D Correlation
2DM
2XS
2XE
2WR
2YS
2YE
2WY
2DR
2DF
(list of values)
Correlation Mode
SQ = Squared Correlation
RG = Regression
CO = Correlation
SY = Synchron
AS = Asynchron
(numerical)
2D X Start Frequency
(numerical)
2D X End Frequency
(numerical)
2D Whole X Range
(numerical)
2D Y Start Frequency
(numerical)
2D Y End Frequency
(numerical)
2D Whole Y Range
(numerical)
2D Digital Resolution
(numerical)
2D Reduction Factor
DMA Extraction
DMA
DMF
DMP
DMS
(numerical)
(numerical)
(numerical)
(numerical)
Smoothing, Derivative
QSP
QOD
(numerical)
(numerical)
Compare Spectra
QFX
QLX
QWR
(numerical)
(numerical)
(numerical)
Identitity Test
QFB
QFC
QFD
QFE
QFF
QFH
QFI
QFJ
QFK
QFL
QI0
QI1
(text)
Identity Test Methods
(text)
Method name
(numerical)
Use AQP Flag (0: No; 1: Yes)
(numerical)
Check Best Hit (0: No; 1: Yes)
(numerical)
Expected Reference ID
(numerical)
1st SNM char. for check
(numerical)
Length of SNM part for check
(numerical)
Ident: 0: Analy; 1: Add List; 2: Rem. All
(text)
Ident: Path of Fl. to be Added
(text)
Ident: Name of Fl. to be Added
(numerical)
Ident: BlockID of Fl. to be Added
(list of values)
Sort for Expected Reference
SNM = Sample Name
ID = ID
FIL = File Name
OPUS-NT Programming
1115
QI2
QQN
QQO
(numerical)
(binr)
(binr)
Cluster Analysis
QCA
QCB
QCH
QCI
QCJ
QCK
QCL
(text)
Method Path
(text)
Method Name
(text)
text-List Path
(text)
text-List Name (incl. Ext.)
(list of values)
Print/Plot
NO = No
DEN = Dendrogram
DIA = Diagnosis
BOT = Both
(list of values)
For Making Dendro
FIL = File Name
SNM = Sample Name
NUM = File Number
NO = No Name Markers
(numerical)
# of Classes (for Diagn.)
Peak Picking
FXP
LXP
QP0
QP3
QP4
QP5
QP6
QP7
QP8
QP9
PTR
PPM
NSP
PSM
WHR
(numerical)
(numerical)
(list of values)
NO = No
YES = Yes
(numerical)
(list of values)
NO = No
YES = Yes
(numerical)
(list of values)
NO = No
YES = Yes
(numerical)
(list of values)
NO = No
YES = Yes
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
Black Body
QTE
QPH
1116
(numerical)
(numerical)
New Entries
0:Energy; 1:Photons
OPUS-NT Programming
Raman Correction
QC0
QC1
QC2
QC3
QC4
QC5
(numerical)
(numerical)
(numerical)
(text)
(text)
(numerical)
Averaging
QA0
QA1
QA2
QA3
QA4
QA5
QAE
QAF
QAG
QAH
QAL
QAM
QAN
QAO
QD0
(numerical)
1: Consider Scans
(numerical)
1: Normalized Spectra
(numerical)
1: Average Report
(text)
Av. Spectrum Path
(text)
Av. Spectrum
(numerical)
1: Add to List in Ident Method
(list of values)
Create Std-Dev Spectrum
NO = No
YES = Yes
(list of values)
Update Av. Spectrum
NO = No
YES = Yes
(text)
Updated Av. Spectrum Path
(text)
Updated Av. Spectrum
(list of values)
Av.: Source of Orig. Spectra
LIS = File List
FIL = File Name
(text)
Av: Orig. Spectra Path
(text)
Av: Orig. Spectra
(numerical)
Av: Orig. Spectra Block ID
(numerical)
1: New Entries
Quality Test
QQ0
QQ1
QQ2
QQ3
QQ4
QQ5
QQ6
QQ7
QQ8
QQ9
QQA
QQB
QQC
QQD
QQH
QQE
QQF
QQG
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
x-Start (x range 0)
x-End (x range 0)
ymax-ymin(x range 0) must be >
ymax-ymin(x range 0) must be <
x-Start (x range 1)
x-End (x range 1)
x-Start (x range 2)
x-End (x range 2)
x-Start (x range noise)
x-End (x range noise)
ymax (x range noise) must be <
S/Noise (x range 1) must be >
S/Noise (x range 2) must be >
x-Start (x range water)
x-End (x range water)
ymax (x water) must be <
S/Water (x range 1) must be >
S/Water (x range 2) must be >
OPUS-NT Programming
1117
QQI
QQJ
QQK
QQL
QQM
(numerical)
(numerical)
(numerical)
(text)
(text)
2D Correlation
QC6
QC7
QC8
QC9
QCC
QCD
QCE
(numerical)
(numerical)
(numerical)
(list of values)
NO = No
YES = Yes
(numerical)
(list of values)
NO =No
YES = Yes
(list of values)
NO = No
YES = Yes
2D-Corr. Asynchronous
Display Limits
XSP
XEP
YMN
YMX
XAU
(numerical)
Left X Display Limit
(numerical)
Right X Display Limit
(numerical)
Lower Y Display Limit
(numerical)
Upper X Display Limit
(list of values)
X - Axis Scaling
NO = Linear
YES = Compressed
Normalization
NME
NFX
NLX
NWR
(numerical)
(numerical)
(numerical)
(numerical)
Frequency Calibration
QF0
MWC
AWC
(list of values)
NO =No
YES = Yes
(numerical)
(numerical)
Baseline Correction
BME
BCO
BPO
1118
(numerical)
(numerical)
(numerical)
Baseline Method
Exclude CO2 - Bands
Number of Baseline Points
OPUS-NT Programming
Make Compatible
CME
(numerical)
AB TR
CCM
(numerical)
Method
Spectrum Calculator
CDI
(numerical)
Permanent Dialog
FOR
(text)
Formula
(numerical)
(numerical)
First Point
Last Point
Cut
CFX
CLX
(numerical)
(numerical)
First Point
Last Point
Convert Spectra
CSD
(numerical)
Method
CarbOx Analysis
FFO
FFC
FME
FUN
FRT
FST
FSI
FCN
FOF
FSL
FCO
FCC
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
Epi Analysis
EFX
ELX
EWR
EMO
EN1
EN2
EN3
ES1
ES2
Bruker Optik GmbH
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
First Point
Last Point
Whole Range (0: no, 1: yes )
Mode
Refraction Index n1
Refraction Index n2
Refraction Index n3
Sign first echo-peak
Sign second echo-peak
OPUS-NT Programming
1119
cm-1
LNE
LME
LYS
LCF
QL0
QL1
QL2
QL3
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
Integration
LPT
LFN
LRM
(text)
(text)
(numerical)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
Quant
QPT
QFN
QP1
QF1
QP2
QF2
CAP
CAF
GAP
GAF
HEV
HWV
HCT
HDF
HAR
QSM
FLC
FLS
LLF
QPP
1120
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
Marker Size
Marker Symbol small circle
Marker Color CLR_NEUTRAL
Frame X Position 3 cm
Frame Y Position 2 cm
Frame dx 12 cm
Frame dy 12 cm
OPUS-NT Programming
(text)
(text)
(text)
(text)
(text)
Macro Parameters
MPT
MFN
MDS
(text)
(text)
(text)
Macro Path
Macro Filename
Macro Description
GRAMS Export
GMN
GMD
(text)
(text)
Macro Filename
Macro Description
(text)
(text)
(text)
(text)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(text)
(text)
(numerical)
(numerical)
(numerical)
(numerical)
Simulation
SXS
SXE
SLA
SER
SEI
SFP
SFS
SVA
SVB
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
OPUS-NT Programming
1121
SVC
SVG
SZL
SWR
SXP
SLI
SLP
SRI
SFV
SPC
SDL
SDF
SDV
SCQ
SPT
SPD
SLS
SDP
SDE
SDD
SLF
(numerical)
Simuls Valence C
(numerical)
Simuls Energy Gap
(numerical)
Simuls Lattice Count
(numerical)
Simul Whole Range
(numerical)
Simul Points
(numerical)
Simul Light From
(numerical)
Simul Polarization
(numerical)
Simul Extract DF Re/Im
(numerical)
Simul DF Values Flag
(numerical)
Simuls Coherence
(numerical)
Simuls Lattice
(numerical)
Simuls Free Carriers
(numerical)
Simuls Valence Electrons
(list of values)
Simul Computed Quantity
ABS = Absorbance
REF = Reflectance
TRA = Transmittance
RRK = Amplitude Reflectivity Coefficient
RTK = Amplitude Transmission Coefficient
(list of values)
Simuls Type
HOM = Homogenious
IHO = Inhomogenious
(text)
Simul Layer Density
(text)
Simul Layer Stack
(text)
Simul Layer DF
(text)
Simul Extract DF
(text)
Simul Layer DF File
(text)
Simul Layer Stack File
Extrapolation
QX0
QX1
QX2
QX3
QX4
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
Extrapol R (0)
Extrapol R (inf.)
Extrapol i1
Extrapol i2
Extrapol ny end
Trace Calculation
QT0
QT1
QT2
QT3
(list of values)
NO = No
YES = Yes
(list of values)
NO = No
YES = Yes
(text)
(text)
x Point Adaption
QAI
QAJ
QAK
1122
(numerical)
(text)
(text)
OPUS-NT Programming
Manipulate GC Blocks
QM5
QM6
LB0
RS1
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(text)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(text)
(numerical)
(text)
(text)
(text)
(text)
(numerical)
(text)
Library Name
Library List
Library Path
Info textfile Name
Path for Library text Definitions
Method File Name
Path for Library Method Definitions
Method ID
Library Edit Mode
Library Store Mode
Spectrum Number
Search Sensitivity
Library Protection
Copyright Note
Password Read
Password Write
Minimum HQ for Spectrum Search
Maximum Hits for Spectrum Search
Spectrum Search Algorithm
Maximum Hits for Info Search
Minimum HQ for Peak Search
Maximum Hits for Peak Search
Maximum Hits for Structure Search
Peak Search Algorithm
Library Description
Structure Search Algorithm
Info Query Name
Info Query Path
Peak Query Name
Peak Query Path
Show Search Report immediately
Excluded Ranges File
Temperature Control
TWK
TPO
TPD
TMP
TCS
TDV
(numerical)
Temperature work for thread
(numerical)
Temperature Port (com 1...n)
(numerical)
Use Com Defaults
(numerical)
Temperature
(text)
Temperature Command String
(list of values)
Temperature Control Device
0 = Eurotherm 800 Series
1 = Lake Shore 320
2 = Linkam 93 Series
3 = Eurotherm 2000 Series
OPUS-NT Programming
1123
(text)
Communication Parameters
You will find parameters used for data output etc. listed in chapter 10.
JCAMP Parameters
JCC
ORP
JDT
(list of values)
Generate JCAMP-DX Compound Files
1 = Yes
0 = No
(list of values)
Ordinate Precision
32 = 32 Bit
16 = 16 Bit
(list of values)
JCAMP-DX Data Type
PAC = Packed
SQD = Squeezed/Dup
DD = Difference/Dup
REN
SAN
DAP
(numerical)
(list of values)
1 = Yes
0 = No
(text)
(text)
(text)
Copy Flags
Overwrite Existing Files
SOX
QD1
QD2
(text)
(numerical)
(numerical)
(list of values)
1 = Yes
0 = No
(list of values)
1 = Yes
0 = No
(numerical)
(numerical)
1124
(numerical)
(numerical)
(text)
(list of values)
1 = Yes
OPUS-NT Programming
YON
DBT
0 = No
(list of values)
1 = Yes
0 = No
(numerical)
y Values only
External Program
XPF
XST
XPR
XPA
XWI
XWS
XCW
XSB
XEM
XDM
XVP
DDE
DDS
DDT
DDI
DDD
VBS
VBP
VBW
(numerical)
(numerical)
(text)
(text)
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(text)
(numerical)
(numerical)
(text)
(text)
(text)
(text)
(text)
(text)
(numerical)
Pipe Parameters
PIN
PIS
PIF
CO1
CO2
CO3
CFI
COT
TIO
(text)
(text)
(numerical)
(numerical)
(numerical)
(numerical)
(text)
(text)
(numerical)
Pipe Name
Pipe String
Pipe Flags
COMmunication Flags
Separator/Terminator Bytes for COMmunication
Byte Count for COMmunication
COMmunication Output File
COMmunication Output text
Timeout
Plot Parameters
Parameters used to plot data.
PUN
PL0
LFO
PL1
PL2
PL3
(list of values)
CM = cm
IN = inch
(numerical)
(text)
(numerical)
(numerical)
(numerical)
OPUS-NT Programming
1125
PL4
PL5
PL6
PL7
PL8
LGO
PDV
SCP
SCN
PRP
LPP
POP
POF
PLO
PF1
PFI
PLI
PRF
PPA
PWO
PDH
PTX
PLP
PRN
MLW
COS
M00
M01
M02
M03
M04
M05
M06
M07
M08
M09
1126
(numerical)
(numerical)
(numerical)
(numerical)
(numerical)
(list of values)
NO = No
YES = Yes
(text)
(text)
(text)
(numerical)
(numerical)
(text)
(text)
(text)
(numerical)
(numerical)
(numerical)
(numerical)
(text)
(text)
(numerical)
(text)
(text)
(text)
(numerical)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
(text)
Length Stroke 0 - 1
Length Stroke 1 - 2
Length Stroke 2 - 3
Distance Peak <--> Line
Peak Stroke Length
BRUKER Logo
Plot Device
Script Path
Script Name
Printer Port (LPTn)
Lines per Page
Plot & Print Output Path
Plot & Print Output File Name
Print Log File Name
Plot Option Flags
First Item Printed
Last Item Printed
Print Option Flags
Polyline Parameters
Plot WYSIWYG Options
Plot Dialog Window Handle
Print text
Print Log Position on Screen
Print Device
Minimum Spectrum Line Width in Plot
Color Settings in Plot
Plot Message # 0
Plot Message # 1
Plot Message # 2
Plot Message # 3
Plot Message # 4
Plot Message # 5
Plot Message # 6
Plot Message # 7
Plot Message # 8
Plot Message # 9
OPUS-NT Programming
12.1
12.2
OPUS-NT Programming
The
121
Syntax:
The name of the command and the syntax that has to be applied. Mandatory
exchange parameters are indicated with < >, optional parameters are enclosed
in square brackets [ ].
Description:
A description of the action performed by the command.
Return Value:
A list of the possible return values.
Return Value 2:
Return Value 3:
Some commands return additional text after confirming the execution with OK;
in this case they must be read.
Errors:
A list of possible error messages.
Comments:
Notes and further comments about the command.
12.3
12.3.1
Overview
122
OPUS-NT Programming
ASCII
BINARY
DATA_VALUES
DATA_POINTS
READ_HEADER
READ_DATA
WRITE_HEADER
WRITE_DATA
COPY_DATA
LOAD_FILE
UNLOAD_FILE
START_MACRO
FILE_PARAMETERS
OPUS_PARAMETERS
READ_PARAMETER
12.3.2
CLOSE_PIPE
Syntax:
CLOSE_PIPE
Description:
Closes the pipe connection.
Return Value:
OK
Comment:
Although it is not strictly required, this command should be send if no further
communication with OPUS is necessary. The corresponding program pipe will
be closed by OPUS and the resources returned.
12.3.3
COUNT_ENTRIES
Syntax:
COUNT_ENTRIES
Description:
Returns the number of data blocks that have been selected in the Select File dialog of the External Program function.
Return Value:
OK
Bruker Optik GmbH
OPUS-NT Programming
123
Return Value 2:
<Number of data blocks>
Comment:
This command ensures that all files or data blocks selected in the Select File
dialog of the External Program function can be accessed.
12.3.4
READ_FROM_ENTRY
Syntax:
READ_FROM_ENTRY <Number>
Description:
This command specifies the data block accessed by the READ_DATA command.
Return Value:
OK or error message.
Error:
Syntax: READ_FROM_ENTRY <Number>
Entry number out of range
Return Value 2:
<Complete path of the OPUS file>
<File number>
<Data block name>
Comment:
The argument to this command is the number of an entry in the Client/Server
file list (between 1 and the number returned from the COUNT_ENTRIES command), from which the client program intends to read. If no error occurs, the
complete file name (including drive and path), as well as the data block name of
the selected file in text format will be returned as the second return value. The
format of the data block name is identical to the one used in the history function.
The file name returned by the command is hyphenated and followed by the
number of the copy (clonecount) for further use with the command line.
124
OPUS-NT Programming
12.3.5
WRITE_TO_ENTRY
Syntax:
WRITE_TO_ENTRY <Number>
Description:
This command specifies the data block accessed by the WRITE_DATA command.
Return Value:
OK or error message.
Error:
Syntax: WRITE_TO_ENTRY <Number>
Entry number out of range
Return Value 2:
<Complete path of the OPUS file>
<File number>
<Data block name>
Comment:
The argument to this command is the number of an entry in the Client/Server
file list (between 1 and the number returned from the COUNT_ENTRIES command). If no error occurs, the complete file name (including drive and path), as
well as the name of the data block in text format will be returned as the second
return value. The name of the data block is returned in the same format used in
the history function.
The file name returned by the command is hyphenated and followed by the
number of the copy (clonecount) for further use with the command line.
12.3.6
READ_FROM_FILE
Syntax:
READ_FROM_FILE <Filename> or <File number>
Description:
Specifies the OPUS file from which the client program intends to read. The
OPUS-NT Programming
125
argument to this command is the file name which can be specified with or without hyphens. Optionally, the clonecount can be stated. If the file was already
loaded in OPUS using this name (including the correct clonecount), this copy
will be used. Otherwise, the file will automatically be loaded. For reasons of
compatibility to OPUS-OS/2 the file can still be accessed via an internal file
number, but this number is no longer limited to the region between 1 to 699.
Return Value:
OK or error message.
Error:
Syntax: READ_FROM_FILE <File name> or <File number>
File not Found
Return Value 2:
<Complete path of the OPUS file>
<File number>
Comment:
Specifies the OPUS file from which the client program intends to read. This
command is only able to select a file; the READ_FROM_BLOCK command
must subsequently be used to specify the data block in the file, from which to
read.
The error message File not Found can have multiple causes. In general, it
indicates an error while accessing the file.
The file name returned by the command is hyphenated for further use in the
command line and is followed by the number of the copy (clonecount).
12.3.7
WRITE_TO_FILE
Syntax:
WRITE_TO_FILE <File name> or <File number>
Description:
Specifies the OPUS file to which the client program intends to write. The argument to this command is the file name which can be specified with or without
hyphens. Optionally, the clonecount can be stated. If the file was already
loaded in OPUS using this name (including the correct clonecount), this copy
will be used. Otherwise, the file will automatically be loaded. For reasons of
126
OPUS-NT Programming
compatibility to OPUS-OS/2 the file can still be accessed via an internal file
number, but this number is no longer limited to the region between 1 to 699.
Return Value:
OK or error message.
Error:
Syntax: WRITE_TO_FILE <File name> or <File number>
File not Found
Return Value 2:
<Complete path of the OPUS file>
<File number>
Comment:
Specifies the OPUS file to which the client program intends to write. This command is only able to select a file; the WRITE_TO_BLOCK command must subsequently be used to specify the data block in the file to which to write.
The error message File not Found can have multiple causes. In general, it
indicates an error while accessing the file.
The file name returned by the command is hyphenated for further use in the
command line and is followed by the number of the copy (Clonecount).
12.3.8
READ_FROM_BLOCK
Syntax:
READ_FROM_BLOCK <Block name>
Description:
Specifies the data block from which the client program intends to read. The
command always refers to the file that was last specified with the
READ_FROM_ENTRY or the READ_FROM_FILE command.
Return Value:
OK or error message.
Error:
Syntax: READ_FROM_BLOCK <Block name>
OPUS-NT Programming
127
12.3.9
WRITE_TO_BLOCK
Syntax:
WRITE_TO_BLOCK <Block name>
Description:
Specifies the data block from which the client program intends to write. The
command always refers to the file that was last specified with the
WRITE_TO_ENTRY or the WRITE_TO_FILE command.
Return Value:
OK or error message.
Error:
Syntax: WRITE_TO_BLOCK <Block name>
No Filename or Filenumber defined
Unknown blocktype
Block not found
Comment:
The argument to the command is the block type which is also used in reports,
i.e. AB for an absorption spectrum, TR/Multiple for a transmission block
of a 3D file. The command will only be accepted if it was preceded by either
the WRITE_TO_ENTRY or the WRITE_TO_FILE command.
128
OPUS-NT Programming
12.3.10 ASCII
Syntax:
ASCII
Description:
Sets the transfer mode used to transfer data points to ASCII.
Return Value:
OK
Comment:
If this mode is chosen (default mode) all data points will be transferred as
ASCII text. Each data point is followed by an End of Line sequence.
12.3.11 BINARY
Syntax:
BINARY
Description:
Sets the transfer mode used to transfer data points to BINARY.
Return Value:
OK
Comment:
If this mode is chosen, all data points will be transferred as 4 byte IEEE floating-point number (REAL*4 in FORTRAN, FLOAT in C). In this mode, the
data points will not be terminated. Therefore, the number of bytes transferred is
N*4, N being the total number of transferred data points. This mode is faster
than the ASCII mode.
12.3.12 DATA_VALUES
Syntax:
DATA_VALUES
Description:
The parameters of the READ_HEADER, READ_DATA and COPY_DATA
OPUS-NT Programming
129
12.3.13 DATA_POINTS
Syntax:
DATA_POINTS
Description:
The parameters of the READ_HEADER, READ_DATA and COPY_DATA
will be interpreted as data points.
Return Value:
OK
Comment:
The data point numbering starts with ,,1. Floating-point numbers are always
rounded to the next lower integer (e.g. 14.965 will be rounded to 14).
12.3.14 READ_HEADER
Syntax:
READ_HEADER [<X1>[-<X2>] [<Z1>[-<Z2>]]
Description:
Reads the header of a spectrum block and returns the frequency range of the
spectrum. Several options are available.
Return Value:
OK or error message.
Error:
No Filename or Filenumber defined
No Blocktype defined
Error Reading File
Not implemented
1210
OPUS-NT Programming
Return Value 2:
In case of regular spectrum blocks:
<Number of data points (NX = XL - XF + l) in region X>
<Frequency of the first data point in region X>
<Frequency of the last data point in region X>
Return Value 2:
In case of 3D spectrum blocks:
<Number of data points (NX = XL - XF + I) in region X>
<Frequency/number of the first data point in region X>
<Frequency/number of the last data point in region X>
<Number of spectra (NZ = ZL - ZF + 1) in region Z>
<Value (e.g. time) of the first spectrum in region Z>
<Value (e.g. time) of the last spectrum in region Z>
Note:
The output will always be returned as ASCII text, separated by an End of Line
sequence, regardless of the selected data transfer mode.
Comment:
Up to four parameters can be forwarded as command arguments.
<X1>, <X2> define the frequency region of the spectrum block. If <X2> is not
explicitly stated, only one data point in the vicinity of <X1> will be returned. If
no parameters are specified or if <X1> was set to ,,* , all data stored in the
spectrum block will be returned.
<Z1>, <Z2> define the region of the Z axis for which data will be returned (only
for 3D files). If <Z2> is not specified, only data in the vicinity of <Z1> will be
returned. If no parameters are specified or if <Z1> was set to ,,*, all data
stored in the spectrum block will be returned. In the case of regular spectrum
blocks, the parameters <Z1> and <Z2> will be ignored and do not cause an
error message in case they have been stated.
All four parameters can either be entered as integer or as floating-point number
and will be interpreted either as frequencies or as data points, depending on the
settings (see the DATA_VALUES and DATA_POINTS commands).
OPUS-NT Programming
1211
12.3.15 READ_DATA
Syntax:
READ_DATA [<X1>[<X2>]] [<Z1>[-Z2]]
Description:
Reads the header and data points of a spectrum block within the limits indicated. The parameters of the command are similar to the parameters of the
READ_HEADER command.
Return Value:
OK or error message.
Error:
No Filename or Filenumber defined
No Blocktype defined
Error Reading File
Not implemented
Return Value 2:
In case of regular spectrum blocks:
<Number of data points (NX = XL - XF + l) in region X>
<Frequency of the first data point in region X>
<Frequency of the last data point in region X>
<Scaling factor for Y values>
<Y(XF)>, <Y(XF + 1)>, <Y(XF + 2)> ...<Y(XL)>
OK or Error Reading File
Return Value 2:
In case of 3D spectrum blocks:
<Number of data points (NX = XL - XF + 1) in region X>
<Frequency/number of the first data point (XF) in region X>
<Frequency/number of the last data point (XL) in region X>
1212
OPUS-NT Programming
12.3.16 WRITE_HEADER
Syntax:
WRITE_HEADER
Description:
Writes a (new) header for a data block. After the command, the following
parameters must be send as ASCII text:
Return Value:
In case of regular spectrum blocks:
OPUS-NT Programming
1213
12.3.17 WRITE_DATA
Syntax:
WRITE_DATA
Description:
Writes the header and data points into a data block. After the command, the following parameters must be send:
In case of regular spectrum blocks:
<Number of data points (NX = XL - XF + l) in region X>
1214
OPUS-NT Programming
OPUS-NT Programming
1215
Return Value 2:
After the header and all data points have been read by OPUS, either OK or an
error message will be returned.
Comment:
The header values must always be sent as ASCII text, separated by an End of
Line sequence, regardless of the selected data transfer mode. The data points
must be returned either as ASCII text, separated by an End of Line sequence, or
as floating-point numbers without any separator, depending on the selected data
transfer mode.
12.3.18 COPY_DATA
Syntax:
COPY_DATA [<X1>[-<X2>]] [<Z1>[-<Z2>]]
Description:
Copies data points from a data block specified by one of the commands
READ_FROM_ENTRY or READ_FROM_FILE and READ_FROM_BLOCK
to a data block specified by either the WRITE_TO_ENTRY or
WRITE_TO_FILE and WRITE_TO_BLOCK command (for parameters see
READ_HEADER).
Return Value:
After receiving the command:
OK or error message.
Return Value 2:
After processing the command:
OK or error message.
Error:
No Filename or Filenumber defined
No Blocktype defined
Not implemented
Error Reading File
Comment:
1216
OPUS-NT Programming
The copy process take place within OPUS. Therefore, no data points are transferred via a pipe.
12.3.19 LOAD_FILE
Syntax:
LOAD_FILE <File name>
Description:
Loads the indicated file into OPUS.
Return Value:
OK or error message.
Error:
Syntax: LOAD_FILE <File name>
Error reading file
Return Value 2:
<Path and name of the file>
<File number>
Comment:
OPUS loads the file even if it has already been loaded before. In this case
another copy (clone) is generated.
The file name returned by the command is hyphenated for further use in the
command line and is followed by the number of the copy (Clonecount).
12.3.20 UNLOAD_FILE
Syntax:
UNLOAD_FILE <File name> or <File number>
Description:
Unloads a file from OPUS selection line. The argument to this command is the
file name (including clonecount).
Return Value:
OPUS-NT Programming
1217
OK or error message.
Error:
Syntax: UNLOAD_FILE <File name> or <File number>
File not loaded
Return Value 2:
<Path and name of the file>
<File number>
Comment:
OPUS unloads the selected file. The complete path and file name, as well as the
entry number will be returned. If the path of the file is not specified, OPUS
searches the Data Path directory for the file.
For reasons of compatibility to OPUS-OS/2 the file can still be accessed via an
internal file number, but this number is no longer limited to the region between
1 to 699.
The file name returned by the command is hyphenated for further use in the
command line and is followed by the number of the copy (clonecount).
12.3.21 START_MACRO
Syntax:
START_MACRO <Macro file name>[<Number of input parameters>]
Description:
Starts an OPUS macro. Input parameters can be forwarded to the macro. If
parameters are exchanged, the total number of parameters must be defined as
the second parameter. If this number is omitted, then it will be set to 0; in this
case, no parameters are read. If the number of input parameters is larger than 0,
the input parameters <input parameter 1>, <input parameter 2>, ...., <input
parameter N> have to be sent by the client program. In addition, the macro can
return parameter values to the client program.
Return Value:
Immediately after the command execution (i.e. directly after the starting the
macro):
OK or error message.
1218
OPUS-NT Programming
Return Value 2:
After macro execution:
OK or error message.
Return Value 3:
only if the macro returned parameters:
<Number of return value parameters>
<Return value parameter 1>
< Return value parameter 2>
...
<Return value parameter N>
Return Value 4:
only if the macro returned parameters:
OK or error message.
Error:
Syntax: START_MACRO <Macro File> <#Parameter>
Error in Opus Command Line Execution - ID: %d
Comment regarding the command:
When executing the command the following order has to be maintained:
Send command including the macro name and the number of input
parameters (optional).
Read return value: OK or error message.
Send input parameter.
Read return value: OK or error message.
Read return value parameter.
The individual input parameters must be separated by End of Line sequences.
Macro parameters can also directly follow a command; in this case the second
OK or error message will not be send.
OPUS-NT Programming
1219
12.3.22 FILE_PARAMETERS
Syntax:
FILE_PARAMETERS
Description:
After this command, the READ_PARAMETER command reads a parameter
from the data block of a file specified by the commands
READ_FROM_ENTRY, READ_FROM_FILE or READ_FROM_BLOCK.
Return Value:
OK
Comment:
This is the default setting for the READ_PARAMETER command.
1220
OPUS-NT Programming
12.3.23 OPUS_PARAMETERS
Syntax:
OPUS_PARAMETERS
Description:
After this command, READ_PARAMETER reads a parameter from the OPUS
default parameter set.
Return Value:
OK
12.3.24 READ_PARAMETER
Syntax:
READ_PARAMETER <Parameter name>
Description:
Reads a parameter either from a specified data block of an OPUS file or from
the standard OPUS parameter set.
Return Value:
OK or error message.
Error:
Syntax: READ_PARAMETER <parameter name>
No Filename or Filenumber defined
No Blocktype defined
Parameter not found
Invalid Parameter Name
Return Value 2:
<Parameter value>
Comment:
The parameter name forwarded as argument to the command consists of a threecharacter abbreviation (see chapter 11). After the confirmation by OPUS, the
parameter value will be transferred as ASCII text.
OPUS-NT Programming
1221
12.3.25 WRITE_PARAMETER
Syntax:
WRITE_PARAMETER <Parameter name> <Parameter value>
Description:
The WRITE_PARAMETER command writes a parameter or changes an existing one in the OPUS file specified by either READ_FROM_ENTRY or
READ_FROM_FILE and READ_FROM_BLOCK.
Return Value:
OK or error message.
Error:
Syntax: WRITE_PARAMETER <Parameter name> <Parameter value>
No Filename or Filenumber defined
No Blocktype defined
Parameter not found
Invalid Parameter Name
Comment:
The parameter name forwarded as argument to the command consists of a threecharacter abbreviation.
The parameter value will be forwarded as ASCII text file, i.e. numerical values
have to be converted to ASCII strings.
12.3.26 RUN_MACRO
Syntax:
Equivalent to START_MACRO
Description:
The RUN_MACRO command starts a macro. Contrary to START_MACRO,
the control is returned immediately after the macro was started. The
RUN_MACRO command does not wait for the macro to terminate and also
doesnt return any results.
1222
OPUS-NT Programming
Return Value:
After the command:
OK or error message.
Return Value 2:
After transferring the input parameter:
OK or error message.
Return Value 3:
<MacroID>: a macro identification number unique for each macro session.
Error:
Similar to START_MACRO
Comment:
See also START_MACRO.
To access the results of the macro started, the MACRO_RESULTS commands
is used.
The returned <MacroID> is used as parameter for the MACRO_RESULTS and
the KILL_MACRO commands.
12.3.27 MACRO_RESULTS
Syntax:
MACRO_RESULTS <MacroID>
Description:
The MACRO_RESULTS command retrieves the result parameters of a macro
session that was started with the ID <MacroID>, using the RUN_MACRO command.
Return Value:
OK or error message.
Return Value 2:
0 or 1 to indicate whether the macro has already finished or is still running.
OPUS-NT Programming
1223
Return Value 3:
Containing the results, if the macro was terminated. For a format description
see START_MACRO.
Error:
Syntax: MACRO_RESULTS <MacroID>
Invalid Macro ID
Comment:
In combination with the RUN_MACRO command, this command allows client
programs to run different tasks while the macro is still running. Use this command to frequently check, whether the macro has finished and to obtain the
return parameters.
12.3.28 KILL_MACRO
Syntax:
KILL_MACRO <MacroID>
Description:
KILL_MACRO terminates a macro session started by RUN_MACRO with the
specified macro ID.
Return Value:
OK or error message.
Error:
Syntax: KILL_MACRO <MacroID>
Invalid Macro ID
Comment:
In combination with the RUN_MACRO command this command allows client
programs to run different tasks while the macro is still running. Under certain
conditions a client program can use this command to stop a macro that is still
running. This corresponds to the Abort Task command of the OPUS task bar.
1224
OPUS-NT Programming
Obsolete Commands
12.4
Obsolete Commands
12.4.1
OVERWRITE
Syntax:
OVERWRITE
Description:
Allows the subsequent commands to overwrite files and data blocks.
Return Value:
OK
Comment:
Subsequent to this command, the following commands are allowed to overwrite
files and data blocks:
WRITE_TO_ENTRY
WRITE_TO_FILE
WRITE_TO_BLOCK
12.4.2
PRESERVE
Syntax:
PRESERVE
Description:
Prevents files and data blocks from being replaced.
Return Value:
OK or error message.
Error:
Set OVERWRITE mode to replace blocks
OPUS-NT Programming
1225
Comment:
Subsequent to this command, the following commands cannot replace existing
files and data blocks:
WRITE_TO_ENTRY
WRITE_TO_FILE
WRITE_TO BLOCK
If an existing data block was specified in a WRITE_TO_BLOCK command,
OPUS returned the message Set OVERWRITE mode to replace blocks.
In case of a WRITE_TO_ENTRY or WRITE_TO_FILE command, the file
name extension was incremented until the first non-existing file was obtained.
Example:
Assume the files TEST.2 and TEST.3 already exist in the current OPUS\DATA
directory. The WRITE_TO_FILE TEST.1 command is sent twice. The first
time the command is executed and generates the file TEST.1. The second time,
the file name extension is incremented until the first non-existing file name is
obtained (TEST.1), because it is not allowed to replace the now existing file
TEST.1.
12.4.3
TIMEOUT
Syntax:
TIMEOUT <Delay>
Description:
Sets a delay time (in seconds) for the pipe, which may not be replaced during
read and write processes.
Return Value:
OK or error message.
Error:
Invalid time limit
Syntax: TIMEOUT<Seconds>
Comment:
The delay is an integer between l and 1000. Without this command the default
1226
OPUS-NT Programming
New Commands
12.5
New Commands
The first view commands of this section serve to further specify the binary
transfer mode. They mainly concern the data exchange with scripts. Because
scripts allow no direct memory access, the data must be enclosed in a variable
field to allow binary data exchange. Hence, the single elements are assigned a
certain type: BYTE_MODE, INT_MODE, FLOAT_MODE, and
DOUBLE_MODE allow to define, whether the binary OPUS data will be contained in a BYTE, INTEGER, FLOAT, or DOUBLE field in a script.
In case of a pipe, the respective memory region can be transferred directly,
which then will be interpreted on the receiving side.
No binary return values are allowed when using DDE connections; these are
available in the HEXSTRING_MODE.
12.5.1
BYTE_MODE
Syntax:
BYTE_MODE
Description:
Sets the binary transfer mode to single bytes.
Return Value:
OK
12.5.2
INT_MODE
Syntax:
INT_MODE
Description:
Sets the binary transfer mode to integer.
Return Value:
OK
OPUS-NT Programming
1227
12.5.3
FLOAT_MODE
Syntax:
FLOAT_MODE
Description:
Sets the binary transfer mode to floating-point numbers.
Return Value:
OK
12.5.4
DOUBLE_MODE
Syntax:
DOUBLE_MODE
Description:
Sets the binary transfer mode to double-precision.
Return Value:
OK
12.5.5
HEXSTRING_MODE
Syntax:
HEXSTRING_MODE
Description:
Sets the binary transfer mode to text.
Return Value:
OK or error message.
Comment:
DDE connection default settings for binary mode.
The data is converted to individual strings of numbers, depending on the mode
chosen (BYTE_MODE, INT_MODE, FLOAT_MODE and DOUBLE_MODE)
and will be transmitted as text.
1228
OPUS-NT Programming
New Commands
12.5.6
FLOATCONV_MODE
Syntax:
FLOATCONV_MODE ON|OFF
Description:
Switches the conversion of floating-point numbers on and off, when using
binary transfer mode.
Return Value:
OK or ON|OFF
Comment:
When using a pipe for binary data transfer under OS/2, a scaling factor was
transferred prior to the actual data. This factor was also transferred binary, but
compared to the data transfer at double-precision (8 instead of 4 bytes). In
OPUS-NT, this factor is found in the first element of the returned field.
If FLOATCONV_MODE is not selected for the binary data transfer to a script,
the first 8 bytes of data (the double-precision scaling factor) will be misinterpreted as two single-precision floating-point numbers.
If neither ON nor OFF is forwarded as parameter the return value text provides the current settings.
12.5.7
GET_DISPLAY
Syntax:
GET_DISPLAY
Description:
Provides an identification number of the currently active display window.
Return Value:
OK
Return Value 2:
<WindowID>
Comment:
The number returned can be used as parameter for the SET_WINDOW,
OPUS-NT Programming
1229
12.5.8
SET_WINDOW
Syntax:
SET_WINDOW <WindowID>
Description:
The window specified by the identification number will be promoted to be the
active display window for the current C/S session.
Return Value:
OK or error message.
Error:
Syntax: SET_WINDOW <Window>
Comment:
If new files are loaded or generated by another OPUS function, they will be displayed in the currently active window. The function is used to define this window.
12.5.9
NEW_WINDOW
Syntax:
NEW_WINDOW <Window type>
Description:
Creates a new window of the type specified.
Return Value:
OK or error message.
Error:
Syntax: NEW_WINDOW <Window type>
Error creating View
Comment:
The window type defines, that for example a new report window will be gener-
1230
OPUS-NT Programming
New Commands
ated.
12.5.10 CLOSE_WINDOW
Syntax:
CLOSE_WINDOW <WindowID>
Description:
Closes the window specified by the <WindowID>.
Return Value:
OK or error message.
Error:
Syntax: CLOSE_WINDOW <Window>
Comment:
The parameter <WindowID> necessary to address the display window can
result from either NEW_WINDOW or from GET_DISPLAY.
12.5.11 POSITION_WINDOW
Syntax:
POSITION_WINDOW <WindowID> <x> <y> <cx> <cy>
Description:
Positions the display window specified by <WindowID> at the coordinates
<x>, <y> and re-sizes it to <cx>, <cy>.
Return Value:
OK or error message.
Error:
Syntax: POSITION_WINDOW <Window> <x> <y> <cx> <cy>\n
Comment:
The parameter <WindowID>, necessary to address the display window, can
result from either NEW_WINDOW or from GET_DISPLAY.
OPUS-NT Programming
1231
12.5.12 GET_LANGUAGE
Syntax:
GET_LANGUAGE
Description:
Retrieves the current language settings of OPUS-NT. The language is set using
the command line argument /LANGUAGE when starting OPUS.
Return Value:
OK
Return Value 2:
<Language>
Comment:
The name of the language will be returned as text.
12.5.13 GET_OPUSPATH
Syntax:
GET_OPUSPATH
Description:
Retrieves the path of the currently running OPUS program.
Return Value:
OK
Return Value 2:
<Path>
Comment:
The path can be checked in the User Settings dialog box of the Setup OPUS
pull-down menu.
1232
OPUS-NT Programming
New Commands
12.5.14 GET_BASEPATH
Syntax:
GET_BASEPATH
Description:
Retrieves the default path of the currently logged in user.
Return Value:
OK
Return Value 2:
<Path>
Comment:
The path is set in the User Settings dialog box of the Setup OPUS pull-down
menu.
12.5.15 GET_DATAPATH
Syntax:
GET_DATAPATH
Description:
Retrieves the data path of the currently logged in user.
Return Value:
OK
Return Value 2:
<Path>
Comment:
The path is set in the User Settings dialog box of the Setup OPUS pull-down
menu.
12.5.16 GET_WORKPATH
Syntax:
GET_WORKPATH
Bruker Optik GmbH
OPUS-NT Programming
1233
Description:
Retrieves the path for work files of the currently logged in user.
Return Value:
OK
Return Value 2:
<Path>
Comment:
The path is set in the User Settings dialog box of the Setup OPUS pull-down
menu.
12.5.17 GET_USERNAME
Syntax:
GET_USERNAME
Description:
Retrieves the name of the currently logged in user.
Return Value:
OK
Return Value 2:
<Name>
Comment:
The user account is set in the User Settings dialog box of the Setup OPUS pulldown menu.
12.5.18 GET_BENCH
Syntax:
GET_BENCH
Description:
Retrieves the configuration file of the currently selected spectrometer.
1234
OPUS-NT Programming
New Commands
Return Value:
OK
Return Value 2:
<OpticsFile>
12.5.19 UPDATE_BENCH
Syntax:
UPDATE_BENCH <OpticsFile>
Description:
Triggers OPUS to initialize the optics configuration using the settings stored in
the <OpticsFile>.
Return Value:
OK or error message.
Error:
Syntax: UPDATE_BENCH <inifile>
RebuildParmText error
12.5.20 COMMAND_SAY
Syntax:
COMMAND_SAY <Text>
Description:
Returns the transferred commands in text format.
Return Value:
<Text>
Comment:
This command serves to test the communication between OPUS and the client
program. It can also be used to forward parameters to scripts. To do this, call
the OpusCommand function of a form created with the OpenForm command (or
selected with FormByName), and forward parameters using COMMAND_SAY
<Parameter>. The form receives the parameter with OnOpusResult <Parameter>.
Bruker Optik GmbH
OPUS-NT Programming
1235
12.5.21 REPORT_INFO
Syntax:
REPORT_INFO
Description:
Retrieves information about the number of main and sub reports of an OPUS
report block.
Return Value:
OK or error message.
Return Value 2:
<#Main reports>
<#Sub reports 1>
...
<#Sub reports N>
Error:
No Filename or Filenumber defined
No Blocktype defined
Error Reading Report
Comment:
First, the total number of main reports is returned, followed by the number of
sub reports contained in each main report. Each line holds only one number.
The information is obtained from the OPUS report block selected by the
READ_FROM_FILE, READ_FROM_ENTRY and READ_FROM_BLOCK
commands.
12.5.22 HEADER_INFO
Syntax:
HEADER_INFO <Main report> <Sub report>
Description:
Returns the number of lines in an OPUS report block header.
1236
OPUS-NT Programming
New Commands
Return Value:
OK or error message.
Return Value 2:
<Lines>
Error:
No Filename or Filenumber defined
No Blocktype defined
Error Reading Report
Comment:
If no sub report is specified, the number of lines in the header of the main report
block is returned instead. If also no main report is specified, the first main
report will be taken.
The information is obtained form the OPUS report block selected by the
READ_FROM_FILE, READ_FROM_ENTRY and READ_FROM_BLOCK
commands.
12.5.23 MATRIX_INFO
Syntax:
MATRIX_INFO <Main report> <Sub report>
Description:
Returns the dimension (number of rows and columns) of a matrix stored in an
OPUS report block.
Return Value:
OK or error message.
Return Value 2:
<Rows>
<Columns>
Error:
No Filename or Filenumber defined
OPUS-NT Programming
1237
No Blocktype defined
Error Reading Report
Comment:
If no sub report is specified, the number of rows in the main reports header will
be returned. If also no main report is specified, the first main report will be
taken.
The information is obtained form the OPUS report block selected by the
READ_FROM_FILE, READ_FROM_ENTRY, and READ_FROM_BLOCK
commands.
12.5.24 MATRIX_ELEMENT
Syntax:
MATRIX_ELEMENT <Main report> <Sub report> <Row> <Column>
Description:
Reads an element from a data matrix of an OPUS report block. The index of the
main/sub report as well as the index of the row and column has to be indicated.
Return Value:
OK or error message.
Return Value 2:
<MatrixElement>
Error:
Syntax: MATRIX_ELEMENT <MainReport> <SubReport> <Row> <Column>
No Filename or Filenumber defined
No Blocktype defined
Error Reading Report
Comment:
If the main report should be accessed, the sub report number must be set to 0.
Determine the total number of rows and columns, using the MATRIX_INFO
command.
1238
OPUS-NT Programming
New Commands
All values are converted to text format prior to the transfer, regardless of the
data format of the element.
The information is obtained form the OPUS report block selected by the
READ_FROM_FILE/READ_FROM_ENTRY, and READ_FROM_BLOCK
commands.
12.5.25 HEADER_ELEMENT
Syntax:
HEADER_ELEMENT <Main report> <Sub report> <Row>
Description:
Reads an element from the OPUS report block header. The index of the main/
sub report as well as the number of the row has to be indicated.
Return Value:
OK or error message.
Return Value 2:
<ElementName>
<ElementContent>
Error:
Syntax: HEADER_ELEMENT <MainReport> <SubReport> <Row>
No Filename or Filenumber defined
No Blocktype defined
Error Reading Report
Comment:
The name of the feature in the selected header row and its value will be
returned. If the main report should be accessed, the sub report number must be
set to 0.
Determine the total number of rows and columns using the HEADER_INFO
command.
All values are converted to text format prior to the transfer, regardless of the
data format of the element.
OPUS-NT Programming
1239
The information is obtained form the OPUS report block selected by the
READ_FROM_FILE/READ_FROM_ENTRY and READ_FROM_BLOCK
commands.
12.5.26 COMMAND_MODE
Syntax:
COMMAND_MODE
Description:
Sets the mode for processing a command line to COMMAND_MODE. This
mode runs commands and programs in the background and returns a message
after termination of the program.
Return Value:
OK
Comment:
Usually, this mode doesnt need to be explicitly set, since these modi are predefined for the different transfer types and interfaces or alternatively are set by
different calls (like OpusExecute).
12.5.27 EXECUTE_MODE
Syntax:
EXECUTE_MODE
Description:
Sets the mode for processing a command line to EXECUTE_MODE. This
mode runs commands and programs in the background, but does not wait for the
programs to terminate. No message will be returned when a program has finished.
Return Value:
OK
Comment:
Usually, this mode doesnt need to be explicitly set, since these modi are predefined for the different transfer types and interfaces or alternatively are set by
different calls (like OpusExecute).
1240
OPUS-NT Programming
New Commands
12.5.28 REQUEST_MODE
Syntax:
REQUEST_MODE
Description:
Sets the mode for processing a command line to REQUEST_MODE. This
mode does not run commands and programs in the background, but waits for the
programs to terminate. The result will be returned as soon as the program terminates.
Return Value:
OK
Comment:
Usually, this mode doesnt need to be explicitly set, since these modi are predefined for the different transfer types and interfaces or alternatively are set by
different calls (like OpusExecute).
12.5.29 CLOSE_OPUS
Syntax:
CLOSE_OPUS
Description:
Terminates OPUS.
Return Value:
No return values.
Comment:
This operation is similar to closing the OPUS user interface window.
12.5.30 TAKE_REFERENCE
Syntax:
TAKE_REFERENCE <Experiment file>
Description:
Performs a reference measurement using the specified <Experiment file>.
OPUS-NT Programming
1241
Return Value:
OK or error message.
Error:
Error in Opus Command Line Execution - ID: %d
12.5.31 MEASURE_SAMPLE
Syntax:
MEASURE_SAMPLE <Experiment file>
Description:
Performs a sample measurement using the specified <Experiment file> and
returns the acquired spectral data as text.
Return Value:
OK or error message.
Return Value 2:
Result File:<File number>
<File name>
Block: <Block type>
<UnitsX>
<UnitsY>
Points: <Number of points>
<x1> <y1>
...
<xn> <yn>
Error:
Error in Opus Command Line Execution - ID: %d
Comment:
All blocks of the new file (specified by the experiment file) are transmitted in
succession as data point tables.
1242
OPUS-NT Programming
New Commands
12.5.32 COMMAND_LINE
Syntax:
COMMAND_LINE <Command line>
Description:
Calls an OPUS function as command lines.
Return Value:
OK or error message.
Return Value 2:
Only in combination with COMMAND_MODE
<ThreadID>
Error:
Error in Opus Command Line Execution - ID: %d
Comment:
In this exception, the keyword COMMAND_LINE can be omitted, because
OPUS tries to interpret all unknown C/S commands in command line notation.
The actual type of command processing depends on the call of the command (in
case of scripts for example OpusExecute), or the settings made by
COMMAND_MODE, EXECUTE_MODE, and REQUEST_MODE.
If COMMAND_MODE was selected, an identification number is supplied for
the background calculation, which can be used to abort the function in case of
STOP_THREAD.
12.5.33 STOP_THREAD
Syntax:
STOP_THREAD <ThreadID>
Description:
Terminates a OPUS processing function which was started by the
COMMAND_LINE function while COMMAND_MODE was selected.
OPUS-NT Programming
1243
Return Value:
OK or error message.
Error:
Syntax: STOP_THREAD <ThreadID>
Comment:
In COMMAND_MODE, COMMAND_LINE starts the function in the background and returns an identification number. This number can be used to abort
the function. This is similar to the Abort Task command of the task manager.
Note: Aborting a program may result in data loss and produce corrupt OPUS
files. Therefore, it should only be used in emergencies.
12.5.34 ACTIVATE_DIALOG
Syntax:
ACTIVATE_DIALOG <Command line>
Description:
Starts the dialog box of an OPUS function.
Return Value:
OK or error message.
Error:
Syntax: ACTIVATE_DIALOG CommandLine()
Comment:
Opening an OPUS function dialog box within another program usually is not
very practical, since the program cannot control the dialog box once it has been
opened. A command line is required as a parameter similar to direct command
processing.
12.5.35 LOAD_EXPERIMENT
Syntax:
LOAD_EXPERIMENT <Experiment file>
1244
OPUS-NT Programming
New Commands
Description:
Loads an experiment file in OPUS and sets the parameters for subsequent data
acquisitions.
Return Value:
OK or error message.
Error:
Syntax: LOAD_EXPERIMENT <parameter file>
Unable to load Experiment file
Comment:
This command is similar to the respective function of the OPUS Measurement
dialog box.
12.5.36 GET_USERRIGHTS
Syntax:
GET_USERRIGHTS
Description:
Retrieves the rights of the current user.
Return Value:
OK
Return Value2:
A list of user rights separated by semicolons or No Rights
Comment:
Allows to adjust programs/scripts to perform different actions, depending on the
user rights.
12.5.37 PACKET_AVAILABLE
Syntax:
PACKET_AVAILABLE <Packet name>
OPUS-NT Programming
1245
Description:
Tests if certain OPUS software packages are installed on a computer.
Return Value:
Yes, No or error message.
Error:
Syntax: PACKET_AVAILABLE <Packet name>
Comment:
Allows a script or program to determine, whether a software package or an
OPUS function is available at all. This applies to QUANT, SEARCH, 3D etc..
12.5.38 GET_CLIENTAREA
Syntax:
GET_CLIENTAREA
Description:
Retrieves the available window size of the OPUS main window. This is dependent on the chosen screen resolution. The result can be used for the positioning
of script forms and spectrum windows etc.
Return Value:
OK
Return Value2:
<width> <height>
Comment:
The returned values can be used as parameters for POSITION_WINDOW.
12.5.39 ACTIVATE_DISPLAY
Syntax:
ACTIVATE_DISPLAY <WindowID>
Description:
A spectrum window can be activated using this command. It will then be dis-
1246
OPUS-NT Programming
New Commands
played in the front. The window specified by the ID number will then be the
active window for displaying the spectra.
Return Value:
OK or error message
Error:
Syntax: ACTIVATE_DISPLAY <window>
Comment:
If new files are loaded or created by other OPUS functions, they will then be
displayed in the currently active window. The active window can be determined
with this function. Whereas SET_WINDOW is only valid for files used in
script, here the active window e.g. for manual loading can be set.
12.5.40 GET_LIMITS
Syntax:
GET_LIMITS <WindowID>
Description:
Lists the actual display limits of the window.
Return Value:
OK or error message
Return Value 2:
<X1> <Y1> <X2> <Y2>
Error:
Syntax: GET_LIMITS <window>
Comment:
The <WindowID> can either be a result of NEW_WINDOW or
GET_DISPLAY
12.5.41 SET_LIMITS
Syntax:
SET_LIMITS <WindowID> <X-start> <X-end> <Y-start> <Y-end>
OPUS-NT Programming
1247
Description:
Sets the display limits of the window to the given values. this is useful to e.g.
enlarge certain areas of the spectrum automatically. The four values determine
the coordinates for the new display limits.
Return Value:
OK or error message
Error:
Syntax: SET_LIMITS <window> <xsp> <xep> <ymn> <ymx>
Comment:
The <WindowID> can either be a result of NEW_WINDOW or
GET_DISPLAY
12.5.42 DISPLAY_BLOCK
Syntax:
DISPLAY_BLOCK <WindowID> <color>
Description:
Displays a datablock of an OPUS file selected by the commands
READ_FROM_ENTRY, READ_FROM_FILE or READ_FROM_BLOCK in
a display window determined by <windowID>. <color> determines the color of
the curve as RGB value.
Return Value:
OK or error message
Error:
No Filename or Filenumber defined
No Blocktype defined
Syntax: DISPLAY_BLOCK <window> <color>
Comment:
The <WindowID> can either be a result of NEW_WINDOW or
GET_DISPLAY
1248
OPUS-NT Programming
New Commands
12.5.43 UNDISPLAY_BLOCK
Syntax:
UNDISPLAY_BLOCK <WindowID>
Description:
Removes a datablock of an OPUS file specified by READ_FROM_ENTRY,
READ_FROM_FILE or READ_FROM_BLOCK from the window identified
by <WindowID>.
Return Value:
OK or error message
Error:
No Filename or Filenumber defined
No Blocktype defined
Syntax: UNDISPLAY_BLOCK <window>
Comment:
The <WindowID> can either be a result of NEW_WINDOW or
GET_DISPLAY
12.5.44 ENUM_STRINGS
Syntax:
ENUM_STRINGS <parametername>
Description:
Possible values for a parameter of type ENUM can be requested at the given
conditions, e.g. depending on the spectrometer.
Return Value:
OK or error message
Return Value 2:
<number of the following valid strings>
<first parameterstring>
...
OPUS-NT Programming
1249
<last parameterstring>
Error:
Syntax: ENUM_STRINGS <parameter name>
Invalid Parameter Name
No Enum Strings
Comment:
The parameter name transferred as an argumentis a three letter abbrevation of a
parameter.
12.5.45 GET_VERSION
Syntax:
GET_VERSION>
Description:
Returns the version of the currently running OPUS NT program.
Return Value:
OK
Return Value 2:
<Version>
Error:
Comment:
Enables the reaction on and the controlling of, different current OPUS versions
from one program.
12.5.46 ASK_THREAD
Syntax:
ASK_THREAD <ProcessID> <special command>
Description:
Enables the interprocess communication of an external program with a running
Opus function.
1250
OPUS-NT Programming
New Commands
Return Value:
OK or error message
Return Value 2:
depending on the transferred command
Error:
ASK_THREAD failed
Invalid Thread ID
Comment:
This direct communication with currently running OPUS functions is intended
only for very special applications. It is mentioned here only for the sake of completeness. However it is actually reserved to internal programming and is used
for the coupling with other instruments. One receives the ProcessID either when
starting the function in the COMMAND_MODE or through
FIND_FUNCTION
12.5.47 FIND_FUNCTION
Syntax:
FIND_FUNCTION <function name>
Description:
Determines whether a certain OPUS function is executed in the background.
The returned ID can be used to stop the function or to communicate with it (if
supported).
Return Value:
OK or error message
Return Value 2:
<ProcessID> for identification
Error:
Syntax: FIND_FUNCTION <FunctionName> or <ThreadID>
Function not found
Comment:
OPUS-NT Programming
1251
12.5.48 WORKBOOK_MODE
Syntax:
WORKBOOK_MODE ON|OFF
Description:
Turns the tabs for switching between different windows at the bottom of the
OPUS window on or off.
Return Value:
OK or ON|OFF
Error:
Comment:
When the buttons are deactivated, switching between different windows is no
longer possible. In the case that a simple user interface is required, one prevents
thereby deviations from the operational sequence intended.
12.5.49 GET_SELECTED
Syntax:
GET_SELECTED
Description:
Supplies the names of the selected (red bordered) files.
Return Value:
OK or error message
Return Value 2:
<name of selected files>
Error:
Error while getting file info
1252
OPUS-NT Programming
New Commands
Comment:
The normal behavior of OPUS, to automatically select marked files for the processing functions, is extended to self-written extension functions.
12.5.50 LIST_BLOCKS
Syntax:
LIST_BLOCKS
Description:
Lists all available spectral data blocks of the OPUS file delivered by the command READ_FROM_ENTRY or READ_FROM_FILE.
Return Value:
OK or error message
Return Value 2:
<number of block names>
<first block name>
...
<last block name>
Error:
No Filename or Filenumber defined
Error getting blocks
Comment:
Enables to determine which blocks are containing an unknown file and then
work with the correct ones accordingly.
12.5.51 SHOW_TOOLBAR
Syntax:
SHOW_TOOLBAR <toolbar>
Description:
Shows a toolbar. Valid parameters are:
OPUS-NT Programming
1253
12.5.52 HIDE_TOOLBAR
Syntax:
HIDE_TOOLBAR <toolbar>
Description:
Hides a toolbar. Valid parameters are:
MENU, STANDARD, COMMANDLINE, PLE, DISPLAY, MEASURE,
MANIPULATE, EVALUATE, MDISPLAY, PLOT_PRINT, MACRO, INFO,
USER, SETUP, FILE, BROWSER, STATUSBAR
Return Value:
OK or Already visible
Error:
Syntax: HIDE_TOOLBAR <toolbarID>
Unknown Toolbar
Comment:
Warning: The adjustments on the desktop made with this function are stored
when leaving OPUS. In order to avoid unwanted effects, all modifications of the
original configuration should be cancelled again before the final termination of
1254
OPUS-NT Programming
New Commands
12.5.53 QUICK_PRINT
Syntax:
QUICK_PRINT
Description:
Activates the function Quickprint. The currently active window will be
printed.
Return Value:
OK
Error:
Comment:
To print a certain window with this function, it has to be activated with
ACTIVATE_DISPLAY first.
OPUS-NT Programming
1255
1256
OPUS-NT Programming
13 Script Commands
In this chapter you find a list of all commands that are available for scripts in
OPUS. They are sorted according to the following categories: commands interpreted by OPUS, native VBScript commands and the functions of the objects
involved.
13.1
13.2
VBScript Language
In the following you will find a simple tutorial that should make you familiar
with the general element of the VBScript language and their use.
13.2.1
In VBScript only one data type exists: variant. Hence, all VBScript functions
return this data type. Variant is able to hold different kinds of information,
depending on how it is used.
In the simplest case, a variant stores numerical values or strings. A variant
behaves like a number if it is used in a numerical context, and like a string if
addressed as text. If you work with data that looks like numbers, variant will
interpret them as such. Of course you can always force numbers to be interpreted as text by enclosing them in hyphens. This is not required if the data is
obviously text.
Variant Subtypes
Besides the simple classification of numerical values and strings, the category
numerical of a variant can be subdivided. For instance, a date value or a time
value can be of the class numerical. In combination with other date and time
values, the result will always be expressed in the respective format. Of course
there exists a large number of other types of numerical information e.g. boolean
values or large floating-point numbers. These classes of information are called
subtypes of variant.
Bruker Optik GmbH
OPUS-NT Programming
131
Script Commands
Description
Empty
variant is not initialized. Numerical variables are set to 0, string variables are a
zero-length string ("").
Null
Boolean
Byte
Integer
Currency
Long
Single
Double
Date
(Time)
contains a number representing a date between 1. January 100 and 31. December
9999.
String
Object
contains an object.
Error
Several conversion functions exist to convert one subtype into another. In addition, the function VarType returns information about how this data ist stored
within variant.
13.2.2
VBScript Variables
Variable Declaration
Variables are explicitely declared in a script using the Dim, Public and Private
statement. For example:
132
OPUS-NT Programming
VBScript Language
Dim DegreesFahrenheit
A variable can also be declared implicitely by using its name at any position in a
script. However, this is looked upon as bad style; you could mistype a variable
name at one or more places which in turn leads to unpredictable results when
executing the script. Hence, the Option Explicit statement was introduced to
force an explicit variable declaration. Therefore, the Option Explicit statement
should always be the first statement in a script.
Naming Restrictions
The standard rules for naming language elements in VBScript also apply to
variable names:
OPUS-NT Programming
133
Script Commands
In the same way (using the index of the array) values can be read from the array
elements:
. . .
AVariable = A(8)
. . .
In order to use such an array, the number of dimensions and their size must be
defined later using the ReDim command. In the following, ReDim is used to set
134
OPUS-NT Programming
VBScript Language
the initial size of the the dynamic array to 25. The subsequent ReDim statement
changes the size to 30, but uses Preserve as keyword, which leaves the content
of the array intact during the change of the size:
ReDim ADataField(25)
. . .
ReDim Preserve ADataField(30)
There is no restriction to how often the size of a dynamic array may be changed.
However, decreasing the size of a array will result in loss of data contained in
the removed elements.
13.2.3
VBScript Constants
A constant is an expressive name that takes the place of a number or a string and
does not change. VBScript defines a number of intrinsic constants.
Creating Constants
User-defined constants are created in VBScripts with the Const statement. It
allows to create numerical and string constants and assign them a literal name:
Const String1 = "This is my string."
Const Age = 49
Note that the string literal is hyphenated (" "). Quotation marks are the most
obvious way to distinguish between string values and numeric values. Date/time
literals are enclosed in number signs (#):
Const Deadline = #6-1-97#
There is no difference between constants created in this way and regular variables. Therefore, you may want to adopt a naming scheme to differentiate constants from variables. This will prevent you from accidentially trying to assign a
value to a constant while your script is running. For example, you might want to
use a vb or con prefix on your constant names, or you might name your
constants in capitals. In any case, you should be able to differentiate between
constants and variables to eliminate confusion as you develop more complex
scripts.
13.2.4
VBScript Operators
VBScript has a full range of operators, including arithmetic operators, comparison operators, concatenation operators, and logical operators.
Operator Precedence
When several operations occur in an expression, each part is evaluated and
resolved in a predetermined order called operator precedence. You can override
OPUS-NT Programming
135
Script Commands
Comparison
Symbol
Description
Logical
Symbol
Description
Symbol
Exponentiation
Equality
Logical negation
Not
Unary negation
Inequality
<>
Logical conjunction
And
Multiplication
Less than
<
Logical disjunction
Or
Division
Greater than
>
Logical exclusion
Xor
Integer division
<=
Logical equivalence
Eqv
Greater
equal to
>=
Logical implication
Imp
Modulus arithmetic
Mod
Addition
Subtraction
String concatenation
&
than
or
Object equivalence
Is
When multiplication and division occur in an expression, each operation is evaluated as it occurs from left to right. Addition and subtraction are handled in the
same way, should they occur together in an expression.
The string concatenation (&) operator is not an arithmetic operator, but in precedence it ranks after all arithmetic operators and before all comparison operators. The Is operator is used for object reference comparison. It does neither
compare objects nor their values but checks whether two object references refer
to the same object.
13.2.5
You can control the flow of your script with conditional statements and looping
statements. Using conditional statements, you can write VBScript code that
makes decisions and repeats actions. The following conditional statements are
available in VBScript:
Statement If...Then...Else
Statement Select Case
136
OPUS-NT Programming
VBScript Language
To execute more than one line of code, the multiple-line (or block) syntax must
be used. This syntax includes the End If statement, as shown in the following
example:
Sub AlertUser(value)
If value = 0 Then
AlertLabel.ForeColor = vbRed
AlertLabel.Font.Bold = True
AlertLabel.Font.Italic = True
End If
End Sub
OPUS-NT Programming
vbRed
True
= True
vbBlack
False
= False
137
Script Commands
Depending on your needs you can add as many ElseIf clauses as you want to
provide alternative choices. Extensive use of the ElseIf clauses often becomes
cumbersome. A better way to choose between several alternatives can bbe realized with the Select Case statement.
Note that the Select Case structure evaluates an expression once at the top of the
structure. In contrast, the If...Then...ElseIf structure can evaluate a different
138
OPUS-NT Programming
VBScript Language
expression for each ElseIf statement. You can replace an If...Then...ElseIf structure with a Select Case structure only if each ElseIf statement evaluates the
same expression.
13.2.6
Loops
Using loops allows you to repeat a group of statements. Some loops repeat
statements until a condition is False; others repeat statements until a condition is
True. There are also loops that repeat statements a specific number of times.
The following looping statements are available in VBScript:
Do...Loop: loops while or until a condition is True.
While...Wend: loops while a condition is True.
For...Next: uses a counter to run statements a specified number of
times.
For Each...Next: repeats a group of statements for each item in a collection or each element of an array.
Using Do Loops
You can use Do...Loop statements to repeatedly run a block of statements. The
statements are repeated either while a condition is True or until a condition
becomes True.
OPUS-NT Programming
139
Script Commands
counter = 0
myNum = 9
Do
myNum = myNum - 1
counter = counter + 1
Loop While myNum > 10
MsgBox "The Loop was repeated " & counter &
" times."
End Sub
1310
OPUS-NT Programming
VBScript Language
Sub ExitExample()
Dim counter, myNum
counter = 0
myNum = 9
Do Until myNum = 10
myNum = myNum - 1
counter = counter + 1
If myNum < 10 Then Exit Do
Loop
MsgBox "The Loop was repeated " & counter &
" times."
End Sub
Using For...Next
For...Next statements are used to run a block of statements a specific number of
times. For loops, use a counter variable whose value is increased or decreased
with each repetition of the loop.
For example, the following procedure causes a procedure called MyProc to be
executed 50 times. The For statement specifies the counter variable x and its
start and end values. The Next statement increments the counter variable by 1.
Sub DoMyProc50Times()
Dim x
For x = 1 To 50
MyProc
Next
End Sub
Using the Step keyword, you can increase or decrease the counter variable by
the value you specify. In the following example, the counter variable j is incremented by 2 each time the loop repeats. When the loop is finished, total is the
sum of 2, 4, 6, 8, and 10.
Sub TwosTotal()
Dim j, total
For j = 2 To 10 Step 2
total = total + j
Next
MsgBox "Die Summe ist " & total
End Sub
To decrease the counter variable, you use a negative Step value. You must
specify an end value that is less than the start value. In the following example,
OPUS-NT Programming
1311
Script Commands
the counter variable myNum is decreased by 2 each time the loop is repeated.
When the loop is finished, total is the sum of 16, 14, 12, 10, 8, 6, 4, and 2.
Sub NewTotal()
Dim myNum, total
For myNum = 16 To 2 Step -2
total = total + myNum
Next
MsgBox "The sum is " & total
End Sub
You can exit any For...Next statement before the counter reaches its end value
by using the Exit For statement. Because you usually want to exit only in certain situations, such as when an error occurs, you should use the Exit For statement in the True statement block of an If...Then...Else statement. If the
condition is False, the loop runs as usual.
13.2.7
VBScript Procedures
In VBScript there are two kinds of procedures; the Sub procedure and the Function procedure.
Sub Procedures
A sub procedure is a series of VBScript statements, enclosed by Sub and End
Sub statements, that perform actions but dont return a value. A Sub procedure
can take arguments (constants, variables, or expressions that are passed by a
calling procedure). If a Sub procedure has no arguments, its Sub statement
must include an empty set of parentheses ().
The following Sub procedure uses two intrinsic (or built-in) VBScript functions, MsgBox and InputBox, to prompt a user for some information. It then displays the results of a calculation based on that information. The calculation is
performed in a Function procedure created using VBScript. The Function procedure is shown after the following discussion.
Sub ConvertTemp()
temp = InputBox("Enter the Temperature in
Fahrenheit.", 1)
MsgBox "The Temperature is " & Celsius(temp) &
" Degree Celsius."
End Sub
1312
OPUS-NT Programming
VBScript Language
Function Procedures
A Function procedure is a series of VBScript statements enclosed by the Function and End Function statements. A Function procedure is similar to a Sub
procedure, but can also return a value. A Function procedure can take arguments (constants, variables, or expressions that are passed to it by a calling procedure). If a Function procedure has no arguments, its Function statement must
include an empty set of parentheses. A Function returns a value by assigning a
value to its name in one or more statements of the procedure. The return type of
a Function is always a Variant.
In the following example, the Celsius function calculates degrees Celsius from
degrees Fahrenheit. When the function is called from the ConvertTemp Sub
procedure, a variable containing the argument value is passed to the function.
The result of the calculation is returned to the calling procedure and displayed
in a message box.
Sub KonvertTemp()
temp = InputBox("Enter the Temperature in
Fahrenheit.", 1)
MsgBox "The Temperature is " & Celsius(temp) &
" Degree Celsius."
End Sub
Function Celsius(GradF)
Celsius = (GradF - 32) * 5 / 9
End Function
To get data out of a procedure, you must use a Function. Remember, a Function
procedure can return a value; a Sub procedure cant.
OPUS-NT Programming
1313
Script Commands
Temp = Celsius(fDegrees)
or
MsgBox "The temperature is " & Celsius(fDegrees) &
" Degree Celsius."
To call a Sub procedure from another procedure, you can just type the name of
the procedure along with values for any required arguments, each separated by a
comma. The Call statement is not required, but if you do use it, you must
enclose any arguments in parentheses.
The following example shows two calls to the MyProc procedure. One uses the
Call statement in the code; the other doesnt. Both do exactly the same thing.
Call MyProc(firstArg, secondArg)
MyProc firstArg, secondArg
Notice that the parentheses are omitted in the call when the Call statement isnt
used.
13.2.8
1314
OPUS-NT Programming
VBScript Language
While this is still an acceptable way to indentify your constants, you may want
to use an alternative naming scheme, now that you can create true constants
using the Const statement. This convention uses a mixed-case format in which
constant names have a con prefix. For example:
conYourOwnConstant
Prefix
Example
Boolean
bln
BlnFound
Byte
byt
BytRasterData
Date (Time)
dtm
DtmStart
Double
dbl
DblTolerance
Error
err
ErrOrderNum
Integer
int
IntQuantity
Long
lng
LngDistance
Object
obj
ObjCurrent
Single
sng
SngAverage
String
str
StrFirstName
Variable Scope
Variables should always be defined with the smallest scope possible. VBScript
variables can have the following scope.
Scope
Visibility
Procedure Level
Script Level
OPUS-NT Programming
1315
Script Commands
Subtype
Prefix
Example
Procedure Level
None
dblVelocity
Script Level
sblnCalcInWork
Prefix
Example
CheckBox
chk
chkReadOnly
cbo
cboDeutsch
CommandButton
cmd
cmdExit
CommonDialog
dlg
dlgFileOpen
Frame
fra
fraLanguage
horizontal ScrollBar
hsb
hsbVolume
Image
img
imgIcon
Label
lbl
lblHelpMessage
Line
lin
linVertical
ListBox
lst
lstPolicyCodes
Spin
spn
spnPages
TextBox
txt
spnLastName
vertical ScrollBar
vsb
vsbRate
Slider
sld
sldScale
OPUS-NT Programming
VBScript Language
because these often change over time, resulting in unnecessary comment maintenance work, or worse, erroneous comments. The code itself and any necessary inline comments describe the implementation.
Arguments passed to a procedure should be described when their purpose is not
obvious and when the procedure expects the arguments to be in a specific range.
Return values for functions and variables that are changed by a procedure, especially through reference arguments, should also be described at the beginning of
each procedure.
Procedure header comments should include the following section headings. For
examples, see the Formatting Your Code section that follows.
Section Heading
Comment Contents
Purpose
Assumptions
Effects
Inputs
Return Values
OPUS-NT Programming
1317
Script Commands
13.2.9
VBScript Functions
Control Flow
Do...Loop
For...Next
For Each...Next
If...Then...Else
Select Case
While...Wend
Array
Dim, Private, Public, ReDim
IsArray
Erase
LBound, UBound
Dates/Times
Date, Time
DateAdd, DateDiff, DatePart
DateSerial, DateValue
Day, Month, Weekday, WeekdayName, Year
Hour, Minute, Second
Now
TimeSerial, TimeValue
Declarations
Const
Dim, Private, Public, ReDim
Function, Sub
Input/Output
InputBox
LoadPicture
MsgBox
1318
OPUS-NT Programming
VBScript Language
Error Handling
On Error
Err
Comments
Comments using or Rem
Constants/Literals
Empty
Nothing
Null
True, False
Conversions
Abs
Asc, AscB, AscW
Chr, ChrB, ChrW
CBool, CByte
CCur, CDate
CDbl, CInt
CLng, CSng, CStr
DateSerial, DateValue
Hex, Oct
Fix, Int
Sgn
TimeSerial, TimeValue
Literals
Empty
False
Nothing
Null
True
Math
Atn, Cos, Sin, Tan
Exp, Log, Sqr
Randomize, Rnd
OPUS-NT Programming
1319
Script Commands
Objects
CreateObject
Err-Objekt
GetObject
Operators
Addition (+), Subtraction (-)
Exponentiation (^)
Modulo arithmetic (Mod)
Multiplication (*), Division (/), Integer Division (\)
Negation (-)
String Concatenation (&)
Equality (=), Inequality (<>)
Less Than (<), Less Than or Equal To (<=)
Greater Than (>), Greater Than or Equal To(>=)
Is
And, Or, Xor
Eqv, Imp
Options
Option Explicit
Procedures
Call
Function, Sub
Rounding
Abs
Int, Fix, Round
Sgn
Script Engine ID
ScriptEngine
ScriptEngineBuildVersion
ScriptEngineMajorVersion
ScriptEngineMinorVersion
Variants
IsArray
IsDate
1320
OPUS-NT Programming
VBScript Language
IsEmpty
IsNull
IsNumeric
IsObject
TypeName
VarType
Miscellaneous
RGB-Functions
Strings
Asc, AscB, AscW
Chr, ChrB, ChrW
Filter, InStr, InStrB
InStrRev
Join
Len, LenB
LCase, UCase
Left, LeftB
Mid, MidB
Right, RightB
Replace
Space
Split
StrComp
String
StrReverse
LTrim, RTrim, Trim
Formatting Strings
FormatCurrency
FormatDateTime
FormatNumber
FormatPercent
Assignments
Set
OPUS-NT Programming
1321
Script Commands
Dictionary
Add
Exists
Items
Keys
Remove
RemoveAll
Count
Item
Key
FileSystemObject
BuildPath
CopyFile
CopyFolder
1322
OPUS-NT Programming
JavaScript
CreateFolder
CreateTextFile
DeleteFile
DeleteFolder
DriveExists
FileExists
FolderExists
GetAbsolutePathName
GetBaseName
GetDrive
GetDriveName
GetExtensionName
GetFile
GetFileName
GetFolder
GetParentFolderName
GetSpecialFolder
GetTempName
MoveFile
MoveFolder
OpenTextFile
Drives
TextStream
Close
Read
ReadAll
ReadLine
Skip
SkipLine
Write
WriteBlankLines
WriteLine
AtEndOfLine
AtEndOfStream
Column
Line
13.3
JavaScript
JavaScript will also be processed by the OPUS Scripting Engine, in this manual
however we document and support mainly VBScript in view of a uniform use.
If you prefer JavaScript you find a good introduction and reference on the following web pages.
OPUS-NT Programming
1323
Script Commands
http://msdn.microsoft.com/scripting/default.htm?/
scripting/jscript/default.htm
13.4
Functions/Events of Forms
The functions and events of an OPUS script form have already been used to
transmit commands to OPUS. In the following you will find an extensive list of
all available functions and events:
Visible
Property of the form, indicates whether the form is visible or not, can either
have the value true or false.
Show
Method to visualize the form.
Hide
Method to hide the form.
Close
Method to close the form and end the script.
Enable
Enables input to the form by keyboard or mouse, in combination with a parameter true or false.
Minimize
Method to minimize the form.
Maximize
Method to maximize the form.
Restore
Method to reset the size of the form to its initial value.
1324
OPUS-NT Programming
Functions/Events of Forms
GetApp
Returns an object of type application. This object represents the OPUS application and in turn provides functions for the handling of forms. This allows to
address other forms dynamically, create new scripts from a running script, and
exchange data with them.
OpenForm
Opens a new form, the name of the script file (including the path) has to
be specified. You can indicate (with the values true or false) if a script
should be used which was already opened and if the file should be opened
in edit mode.
NewForm
Opens a new, blank form.
FormByName
Returns an interface to a form object already running. The internal form
name is transferred as the parameter. The form name is listed as ID in the
forms Properties.
Caption
Caption reads or writes a text as title in the window of the form.
DoEvents
DoEvents hands the process control over to the system until the system has processed all pending events (like paint messages).
Caution! Each time the process control is temporarily transferred to another
thread, care has to be taken that the procedure will not be called by any part of
the code, before the first call is terminated. Otherwise the results are unpredictable.
OpusCommand
Function to start OPUS commands. The function returns immediately after
transmitting the text command. The command is then processed by OPUS and
then the result forwarded to the form by means of an OnOpusResult event.
OpusExecute
Executes an OPUS command. The command will run as background task and
the result will not be returned.
OPUS-NT Programming
1325
Script Commands
OpusRequest
Executes an OPUS command and waits until OPUS has finished the command
processing. The result will be returned directly as text. While normally only a
single event is being processed at a time, this function allows processing of
additional events until OPUS returns its result. The execution of the event
which calls OpusRequest is postponed until OPUS answers. Events, which are
normally called after this procedure may have already been executed. The consequences of the independent time lines have to be taken into account in the
script.
OpusRequestData
Sends commands to OPUS, similar to OpusRequest. In addition, a data array
parameter is exchanged. This parameter is able to transfer a data field to OPUS
or to receive binary data from OPUS. Like in the case of OpusRequest precautions have to be taken to avoid unwanted side effects resulting from parallel
data processing.
SetWindowPos
Positions and dimensions a window using four coordinates: x, y, dx, dy.
SetResult
Sets the result of a script as text, to be transmitted to the requesting OPUS function upon closing the script. To make use of this result, the script has to be
called using the OPUS VisualBasic Script funtion.
GetDocName
Returns the name including path of the active script. Makes it possible to run a
script on different machines by referring to relative path statements. This command becomes first available after the form has been loaded (and not upon loading the form).
HideControl
Hides a control element. The name of the object in the form has to be stated
(e.g. CommandButton1).
ShowControl
Reveals a hidden control element. The name of the element has to be stated in
the form (i.e. CommandButton 1).
1326
OPUS-NT Programming
Microsoft Forms
OnLoad
Event which is triggered upon loading a form.
OnUnLoad
Event which is triggered upon unloading a form.
OnOpusResult
Event which is triggered after an OPUS command has been processed. Three
text fields and if necessary a binary data array will be returned. The contents of
the text fields may vary with the function executed; the first string usually is the
OK statement or an error statement, that indicates whether the command
could be processed successfully. The other fields contain the result. If an
OPUS data manipulation function has been started with a text command, the
first parameter holds the names (numbers) of the resulting files and the second
parameter and return values. If binary data transfer was chosen, the fourth
parameter contains the data array.
OnOpusInform
This function is used by OPUS to transmit a parameter to a script. If for example the function VisualBasic Script is called in combination with script parameters, an OnOpusInform event is triggered at the start of the program. The text is
forwarded to the event handling routine as a parameter.
This event is also employed for the Automatic Accessory Recognition; if an
accessory with AAR support is inserted into the spectrometer the accessory
code will be transferred to a special script.
13.5
Microsoft Forms
Microsoft Forms are control elements that can be used to create and modify custom forms and dialog boxes. They are also used to create VisualBasic for
Application Forms in Microsoft Word. This chapter gives a brief overview of
the existing elements their use.
All functionalities of these controls can be classified to one of the following categories:
Properties By opening the Properties dialog of an element in the Form Editor
you can find out which properties and values are supported by this element. All
available properties will be listed. Usually, they can also be set or read from the
program.
OPUS-NT Programming
1327
Script Commands
Events and related handling routines An event box in the Code/Modules view
shows which events can occur for an object. Here, all required functions can be
created.
Methods Elements use methods to independently process certain tasks. Since
no selection box exist for the methods, short lists are is presented here. An
extensive treatment can be found in Microsofts documentation.
13.5.1
Checkbox
Displays the selection state of an item. Use a CheckBox to give the user a
choice between two values such as Yes/No, True/False, or On/Off. When the
user selects a CheckBox, it displays a special mark (such as an X) and its current setting is Yes, True, or On; if the user does not select the CheckBox, it is
empty and its setting is No, False, or Off. Depending on the value of the TripleState property, a CheckBox can also have a null value.
13.5.2
Combobox Control
Combines the features of a ListBox and a TextBox. The user can enter a new
value, as with a TextBox, or the user can select an existing value as with a ListBox.
Supported Methods:
AddItem
Clear
DropDown
RemoveItem
Copy
Cut
Paste
13.5.3
CommandButton
Starts, ends, or interrupts an action or series of actions. The macro or event procedure assigned to the CommandButton's click event determines what the CommandButton does. For example, you can create a CommandButton that opens
another form. You can also display text, a picture, or both on a CommandButton.
13.5.4
Frame Control
Creates a functional and visual control group. All option buttons in a Frame are
mutually exclusive, so you can use the Frame to create an option group. You
can also use a Frame to group controls with closely related contents. For example, in an application that processes customer orders, you might use a Frame to
group the name, address, and account number of customers.
1328
OPUS-NT Programming
Microsoft Forms
You can also use a Frame to create a group of toggle buttons, but the toggle buttons are not mutually exclusive.
Supported Methods:
Copy
Cut
Paste
RedoAction
Repaint
Scroll
SetDefaultTabOrder
UndoAction
13.5.5
Image Control
Displays a picture on a form. The Image lets you display a picture as part of the
data in a form. For example, you might use an Image to display employee photographs in a personnel form.
The Image lets you crop, size, or zoom a picture, but does not allow you to edit
the contents of the picture. For example, you cannot use the Image to change
the colors in the picture, to make the picture transparent, or to refine the image
of the picture. You must use image editing software for these purposes
13.5.6
Label Control
13.5.7
ListBox Control
Displays a list of values and lets you select one or more. If the ListBox is bound
to a data source, then the ListBox stores the selected value in that data source.
The ListBox can either appear as a list or as a group of OptionButton controls or
CheckBox controls.
Supported Methods:
AddItem
Clear
RemoveItem
13.5.8
Multipage Control
OPUS-NT Programming
1329
Script Commands
name and address; another page might list previous employers; a third page
might list references. The MultiPage lets you visually combine related information, while keeping the entire record readily accessible.
New pages are added to the right of the currently selected page rather than adjacent to it.
Note: The MultiPage is a container of a Pages collection, each of which contains one or more Page objects.
13.5.9
OptionButton Control
Shows the selection status of one item in a group of choices. Use an OptionButton to show whether a single item in a group is selected. Note that each OptionButton in a Frame is mutually exclusive.
If an OptionButton is bound to a data source, the OptionButton can show the
value of that data source as either Yes/No, True/False, or On/Off. If the user
selects the OptionButton, the current setting is Yes, True, or On; if the user does
not select the OptionButton, the setting is No, False, or Off.
Depending on the value of the TripleState property, an OptionButton can also
have a null value.
You can also use an OptionButton inside a group box to select one or more of a
group of related items.
1330
OPUS-NT Programming
Microsoft Forms
to change the month, the day, or the year shown on a date. You can also use a
SpinButton to scroll through a range of values or a list of items, or to change the
value displayed in a text box.
To display a value updated by a SpinButton, you must assign the value of the
SpinButton to the displayed portion of a control, such as the Caption property of
a Label or the Text property of a TextBox. To create a horizontal or vertical
SpinButton, drag the sizing handles of the SpinButton horizontally or vertically
on the form.
Supported Methods:
Copy
Cut
Paste
OPUS-NT Programming
1331
Script Commands
You can also use a ToggleButton inside a Frame to select one or more of a
group of related items.
Supported Methods:
AboutBox
1332
OPUS-NT Programming
Index
Numerics
2D Correlation 11-15, 11-18
3D Files 2-1, 11-3
A
AB/TR conversion 11-19
Abort Macro 5-12
ABTR 10-8
ACTIVATE_DIALOG 12-44
Active X 4-1
Add Variable Button 5-4
Arguments 9-6
Arrays 5-10, 9-2, 13-4
ASCII 12-9
Assemble GC 11-12
Autocorrect 5-2
Average 6-36, 6-39, 10-9
Averaging 11-17
B
Baseline Correction 6-6, 6-8, 6-11, 6-13, 617, 6-18, 6-20, 6-27, 6-29, 6-31, 6-32, 6-33,
6-34, 6-60, 10-10, 11-18
Batch files 2-1
BINARY 12-9
Black Body 11-16
BlackBody 10-10
BUTTON 12-20
Buttons 8-1
BYTE_MODE 12-27
C
C/S Commands
obsolete 12-25
old 12-2
Calculations 5-19
CallMacro 6-68, 6-71, 9-15
Caption 13-25
CarbOx Analysis 11-19
Change Output File 5-14
ChangeDataBlockType 10-21
Checkbox 13-28
Client program 7-4
Client/Server Commands 7-5, 12-1
New 12-27
Client/Server function 5-20
Client/Server Interpreter 12-1, 13-1
Clonecount 3-1, 12-4
Close 13-24
CLOSE_OPUS 12-41
CLOSE_PIPE 12-3
CLOSE_WINDOW 12-31
CloseDisplayWindow 9-32
Cluster Analysis 11-16
COMBOBOX 12-20
Combobox 5-17, 13-28
Command Buttons 6-3
Command Line 3-1, 5-1, 9-6
Command Line Arguments 2-4
Command Line Parameters 4-1
Command Lines 5-8
COMMAND_LINE 12-43
COMMAND_MODE 12-40
COMMAND_SAY 12-35
CommandButton 13-28
Commands
script 13-1
Communication 2-3, 3-2, 7-1
Command Processing 7-2
Error Handling 7-3
Establishing 7-5
Initialization 7-1
Notification 7-3
Parameters 11-24
Program Termination 7-4
Reading Data 7-8
time behaviour 12-20
Compare Spectra 11-15
Compile 5-13
Conditional Statements 13-6
Conformity Test 11-12
Conversion Functions 5-21
Convert 10-10
Convert Spectra 11-19
Copy 9-29
COPY_DATA 12-16
CopyDataBlock 10-21
COUNT_ENTRIES 12-3
Curve Fitting 11-14
Cut 10-11, 11-19
D
Data 2-7
Data Acquisition Parameters 11-4
Data Blocks 3-1, 5-17
Data Block-Specific Parameters 11-1
Data Manipulation 7-7
F
FFT 10-12
File Functions 9-27
File Handling 5-17
FILE_PARAMETERS 12-20
Files for VB Script 2-10
FindString 6-55, 9-14
FLOAT_MODE 12-28
FLOATCONV_MODE 12-29
Flow Control 1-1, 6-3
Flow Control Functions 9-16
For Each...Next 13-12
For...Next 13-11
Form Editor 2-10
FormByName 13-25
Forms 8-1, 13-24
Fourier Transformation 11-13
Frame Control 13-28
FreqCalibration 10-14
Frequency Calibration 11-3, 11-18
FromReportHeader 6-47, 6-71, 9-24
FromReportMatrix 6-47, 9-25
FT-Parameters 11-9
Function Procedures 13-13
G
Generate Straight Line 11-19
GET_BASEPATH 12-33
GET_BENCH 12-34
GET_DATAPATH 12-33
GET_DISPLAY 12-29
GET_LANGUAGE 12-32
GET_OPUSPATH 12-32
GET_USERNAME 12-34
GET_USERRIGHTS 12-45
GET_WORKPATH 12-33
GetApp 13-25
GetArrayCount 6-27, 9-13
GetDisplayLimits 9-33
GetDocName 13-26
GetEnumList 9-25, 9-26
GetLength 9-14
GetMacroPath 6-68, 6-71, 9-13
GetOpusPath 6-18, 6-20, 9-12
GetParameter 6-41, 6-43, 9-24
GetTime 6-61, 6-64, 6-65, 9-30, 9-31
GetUserPath 9-12, 9-13
GetVersion 9-13
Goto 6-51, 6-53, 6-65, 9-17
LibrarySearchStructure 10-27
LibraryStore 10-29
ListBox Control 13-29
Load 6-17, 6-18, 6-27, 6-60
LOAD_EXPERIMENT 12-44
LOAD_FILE 12-17
LoadFile 6-20, 9-28
LoadReference 10-24
Log File 5-15
Loops 5-20, 13-9
M
Macro Converter 5-13
Macro Editor 5-2, 6-1
Macro Parameters 11-21
MACRO_RESULTS 12-23
Macros 2-8, 3-2, 5-1
aborting 5-12
automatic stop 5-13
conversion 5-13
debugging 5-11
execution 5-9
included in Tool Bar 2-11
including OPUS commands 10-1
OS/2 5-14
portable 5-21
Single Step 5-11
Stop Marks 5-12
sub routine calls 5-11
syntax 5-1, 6-1
time behaviour 5-19
writing 5-1, 5-2, 6-1
Make Compatible 11-19
MakeCompatible 10-15
Manipulate GC Blocks 11-23
MATRIX_ELEMENT 12-38
MATRIX_INFO 12-37
Maximize 13-24
MEASURE_SAMPLE 12-42
Measurement 6-3, 6-6, 6-8, 6-11, 6-13, 8-4,
10-23
Measurement Commands 5-16, 10-4
Merge 10-16
Message 6-11, 6-13, 6-47, 6-51, 6-53, 6-55,
6-60, 6-64, 6-65, 6-67, 6-68, 6-71, 6-75, 920
Microsoft Forms 2-8, 13-27
Microsoft Scripting Engine 2-8
Minimize 13-24
V
Variable Dialog Box 5-6
Variables 5-1, 5-17, 6-1
array 9-3
boolean 6-2
BUTTON 9-4
Constants 13-5
declaration 5-3, 9-2
FILE 9-3
file 6-2
Life Time 13-3
Names 13-3
numerical 6-2
Scope 13-15
selection 5-17
text 6-2
type 6-2, 9-1
type conversion 6-3
update 9-4
Validity 13-3
Values 13-3
VBScript 13-2
VARIABLES SECTION 5-1, 9-1
Variant 13-1
VBScript 2-1, 2-8, 8-1, 10-36, 13-1
Coding Converntions 13-14
Constants 13-14
Data Types 13-1
File Handling 13-21
Functions 13-18
Objects 13-16
Operators 13-5
Prozedures 13-12
System Handling 13-21
Variables 13-15
VBScripts
Debugging 13-32
Virtual Dos Machine 2-5
Visible 13-24
VisualBasic 7-1
W
Wavenumber conversion 11-20
While...Wend 13-11
Windows 2-1, 2-5, 5-2, 8-2
Write Datapoint Table 11-24
WRITE_DATA 12-14
WRITE_HEADER 12-13
WRITE_PARAMETER 12-22
WRITE_TO_BLOCK 12-8
WRITE_TO_ENTRY 12-5
WRITE_TO_FILE 12-6
Writing software 2-7
X
x Point Adaption 11-22