Using simple variables
About variables 
You can use variables to assign operator-supplied values to task parameters, provide an initial value for looping, or reference an array in another task. An example of variable usage is as follows: During a protocol run, the software will prompt the operator for aspirate and dispense volumes. The software will use the operator-supplied values during the run.
Instead of writing detailed JavaScript code in the JavaScript task Advanced Settings area, you can type a simple variable assignment and a code snippet directly in a field in the Task Parameters area. The following example shows how to assign a variable called x to the Dispense Volume parameter in the Task Parameters area.
 
Assigning the variable in the Task Parameters area is equivalent to providing the following line of code in the Advanced Settings area:
task.Volume = x;
You can also add a snippet of code after the variable assignment. For example, you can assign the Dispense Volume to x, and then increment it by the same amount in each loop during the protocol run.
 
To prompt the operator for the values to use during the protocol run, you can select the option in the Define Variables task or add User Message tasks at the desired points in the protocol. See Adding user message prompts.
Variable and snippet syntax 
When adding a variable and code snippet in the Task Parameters area, use the following syntax:
=x; <code snippet>
where x is the variable name and <code snippet> is additional code you want to run during the task. Use standard JavaScript rules for the variable name and for the code snippet.
Note: Variables defined here must be predefined in the protocol in the Define Variables task, User Message task, a previous JavaScript code snippet, or in the Advanced Settings area.
Defining variables and adding code snippets 
You can define variables using the following:
Define Variables task. In the Define Variables task, you can define multiple variables and set initial values. For more information, see Define Variables.
Define Plate Set task. In the Define Plate Set task, you can define a variable that identifies a group of process plates to be processed identically. For more information, see Define Plate Set.
Task parameter variables. You can define a variable for almost any parameter. For example, in the Aspirate task, you can define a variable for the Volume parameter. For more information, see Task parameter variables.
Startup Protocol JavaScript task. Using the JavaScript task in the Startup Protocol, you can define multiple variables and assign initial values to them. For more information, see Startup Protocol JavaScript task.
Task parameter variables
The way you define a variable for other tasks depends on the field input style:
Text box format
List format
Time format
Note: Parameters that require fixed values do not accept variables. For example, passwords, deck locations, and IP addresses cannot be assigned the value of a variable.
To assign a variable to a parameter whose value is displayed in a text box:
In the parameter value text box, type the variable assignment and optional code snippet. For syntax requirements, see Variable and snippet syntax.
 
To assign a variable to a parameter whose value can only be selected from a list:
1 In the list, select Variable.
 
The Script variable dialog box opens.
 
2 Type the variable assignment and optional code snippet. For syntax requirements, see Variable and snippet syntax.
Note: The = symbol in front of the text box indicates that the software will automatically add the = symbol in front of the variable.
3 Click OK. The new variable and optional code snippet appear in the parameter value list.
 
To add a variable to a parameter whose value is in the time format (h:mm:ss):
1 In the parameter value box, type = in the h, mm, or ss field. The Script variable dialog box opens.
 
2 Type the variable assignment and optional code snippet. For syntax requirements, see Variable and snippet syntax.
 
Note: The = symbol in front of the text box indicates that the software will automatically add the = symbol in front of the variable.
3 Click OK. The new variable and optional code snippet appear in the parameter field.
 
Startup Protocol JavaScript task
To create multiple variables and assign initial values to them:
1 In the protocol, click Startup Protocol.
 
2 Click Add Process. A Startup process appears.
 
3 Add the JavaScript task.
 
4 In the Advanced Settings area, type the variable assignments.
 
Adding user message prompts 
After adding variables to the desired task parameters, you can add User Message tasks to prompt operators for values at the beginning of the protocol run or at the desired points during the protocol run.
Note: You do not need to add the User Message task when using the Define Variables task. The Define Variables task contains an option to add a user message prompt.
To add User Message tasks:
1 In the Startup Protocol:
Add a task for each variable assigned in a task parameter input field.
Add a task for any variable that you assigned in the Advanced Settings area of a given task. If you added variables in the Advanced Settings area, add the task after the task in the startup protocol.
Alternatively, at the desired points in the Main Protocol, add a task for each variable assigned in a task parameter input field.
2 In the Task Parameters area, type values and select the desired options in the User Message Properties table. For a description of the properties, see User Message.
3 Select User data entry into variable and type the name of the variable in the Variable name box. During the protocol run, the software will prompt the operator for a value and assign it to this variable.
 
 
*If you added multiple variables in the startup protocol, do not use the Variable name property. Instead, use the Body property to instruct the operator to set the variable values in the Advanced Settings area. For details on the Body property, see User Message.
 
Related information
 
For information about...
See...
User Message task
JavaScript task
Using JavaScript in the VWorks software
Using JavaScript utilities
Startup protocols