VWorks Software User Guide : Using macros to create protocols : Adding parameter variables and scripting to a macro
Adding parameter variables and scripting to a macro
This topic assumes that you have an understanding of how to create VWorks protocols, including how to do the following:
 
JavaScript tasks
For details, see...
Define JavaScript variables in the VWorks software
Write programs in JavaScript in the VWorks software
Adding macro parameter variables 
You can expose parameters for individual tasks at the task macro level. For example, you might want to edit the parameter values of tasks contained in the macro without having to open the macro and then open each task to access the task parameters.
To add task parameter variables to the macro:
1 In the Available Macros tab, right-click the macro icon, and then choose Edit from the shortcut menu.
A macro editor tab opens in protocol area and displays the contents of the macro.
2 In the macro editor tab, click the macro icon. The Custom Parameters area replaces the Task Parameters area next to the protocol area.
3 Click Add Variable. A row appears in the Variable Name table.
4 In the new row, click the Variable Name field, and then type the exact same JavaScript variable that appears in the Task Parameters area for the given task parameter.
For example, a macro contains multiple Wash Tips tasks for which you are using the same volume. In the corresponding Task Parameters for each task, you define the Volume parameter as a variable, such as =WashVol_. You use the same variable, WashVol_ as the variable name in the macro’s custom parameters. You can change the volume specified for both tasks by editing the variable value in the macro’s Custom Parameters area.
 
5 In the Initial Value field of the Custom Parameters area, type the value for variable.
For more details on using JavaScript variables for task parameters, see Using simple variables.
6 VWorks Plus only. If you are editing a macro in the macro library and an audit trail is being logged, the Audit Comment dialog box opens. Select or type a reason for the change, and then click OK.
Filtering the macro parameters 
To show all macro parameters:
In the Custom Parameters area, right-click the variables table, and select Show all.
To filter the macro parameter list:
1 In the Custom Parameters area, right-click the variables table, and select Show all.
2 Right-click a cell in the table, and select from the available filtering options:
 
View
Description
Last filter
Returns the display to when the last filter was applied.
Filter by row
Displays the parameters that have the same value as the parameter in the selected row.
For example, if you choose to filter the list based on the initial value of a given parameter. Only the parameters that have the same value as the parameter in the selected row are displayed.
Filter by column
Displays the parameter names that are an exact match of the selected column.
Adding JavaScript to a macro 
You can write JavaScript for a macro in a similar way that you can for a task. For example, you could enable a macro for one set of conditions and disable the macro for all other conditions using the task.skip()method.
At the macro level, you can use only the shared methods of the task object. For a description of the task object’s shared methods, see task object.
To add JavaScript to a macro:
1 In the Available Macros tab, right-click the macro icon, and then choose Edit from the shortcut menu.
A macro editor tab opens in protocol area and displays the contents of the macro.
Figure Macro editor tab and the Advanced Settings area
 
2 In the macro editor tab, click the macro icon. The Custom Parameters area replaces the Task Parameters area next to the protocol area.
3 Click Advanced Settings.
4 In the Script to be executed before task runs box, type your script.
Note: To view the list of available properties for the task object, type task. You can select a property from the list that appears.
Related information
 
For information about...
See...
Adding macros to the macro library
Macro version control
VWorks JavaScript variables
Advanced Parameters area