Macro Command Processor

This utility allows you easily to automate measurements, collect data, save files and output results using a simple programming language.  The macro command processor uses the underlying DDE (Dynamic Data Exchange) syntax and capabilities but does not require a third party application such as Visual Basic.  It provides more flexibility than the data logging utility but without the complexity of Visual Basic.  This is not intended to be a comprehensive programming language - Visual Basic or other external application should be used if more complex control logic is needed.

The macro utility window contains a built in text editor; however, macro files are simple ASCII text files.  The file size is limited to 32KB.

Quick Run Buttons
This optional toolbar allows you to define and label up to 6 buttons that will automatically launch an associated macro file.  Very useful for quick test access.


Macro Control Statements:

1) Send - the Send statement must be followed by one of the DDE commands; it will send this DDE command to the analyzer.  The square brackets are required.  For example,

Send [Run] 

will send the [Run] command to start the analyzer.


2) Output - the Output statement must be followed by one of the DDE request items; it will then write this item to the current macro output text file.  For example,

Output Peak Frequency

will write the current peak frequency value to the output file.


3) SetOutputFile - this statement will set the name of the current output file; all subsequent Output statements will be written to this file until this statement is used again.  For example,

SetOutputFile c:\temp\my_spectral_data.txt

If you do not use this command in your macro script, the Output data will be written to the default output filename as specified in the macro options dialog box.  

4) OutputComment - this statement will simply write the text that follows it to the output file.  For example,

OutputComment Starting Data Collection

will write the string "Starting Data Collection" to the output file.


5) Wait - this statement will cause the macro to wait until the specified time has elapsed before continuing.  There are several variations of this command:

WaitSeconds 4

will wait for four seconds.  The wait time can be a floating point number such as 0.25 (250 milliseconds).

WaitTopOfMinute

will wait for the top of the next whole minute. 

WaitTopOfHour

will wait for the top of the next whole hour. 

WaitClock 1415

will wait until the system clock reaces 1415 (14:15 or 2:15 PM).  Leading zeros are required e.g. (0903)

WaitDate 12/04/2002

will wait until December 4, 2002.  Leading zeros are required.  

If you need to wait until a specific hour on a specific day simply use the WaitDate command followed by the WaitClock and WaitSeconds commands as needed.

WaitMessageBox text

Will display a Message Box window with the text you supply and wait for the user to press Ok.


6) Loop, LoopEnd - this statement pair allows you to iterate through a series of statements.  For example,

Loop 10
   Send [Run]
   WaitSeconds 30
   Output Spectrum
   Send [Stop]
   WaitSeconds 3600
LoopEnd

will execute the commands between the two Loop statements 10 times; in this case it will run the analyzer for 30 seconds, output the spectral data, then stop and wait one hour.  This will repeat 10 times.

Nested loops are not supported.


7) Label, GoTo, Return - these statements allow you to jump to a specific labeled line in the macro file and return.  For example,

Label StartPoint
.
.  more macro statements...
.
GoTo StartPoint

The above statements will cause the macro command processor to jump to the line labelled "StartPoint".  
 
GoTo CollectData
 
Label CollectData
.
. more macro statements
.
Return

This will cause the macro command processor to jump to the line labelled "CollectData".  The "Return" statement will cause the macro to jump to the line just after the GoTo CollectData call.  This allows you to implement simple functions. Up to 10 levels of nested GoTo/Return statements (functions) are supported

8) ; - if the first character on a line is a semicolon, that line will be ignored.  Use this for adding comments to your macro script.

9) AutoDateTime - if this command is embedded in any command that requires a filename, it will be expanded to the current date and time.  For example, if the following command was used on Nov, 26 2002 10:20:11,

SetOutputFile c:\temp\SPL_data_AutoDateTime.txt

will set the output file to c:\temp\SPL_data_2002_11_26_102011.txt 

This feature also works with the DDE commands that use a filename such as [File Save ].  It also works with the OutputComment statement (e.g. OutputComment Starting at AutoDateTime).

10) MacroEnd - will cause the macro command processor to stop.


Other Notes:
Leading or trailing spaces are ignored.
Passing in a macro filename on the command line will start the macro automatically.  To do this create a shortcut to SpectraPLUS-SC and edit the command line in the properties dialog for the shortcut.  For example c:\specplus\bin\specplus.exe c:\specplus\macro\MyTest.mac