![]() |
Example JavaScript task file to set labware barcode |
---|
///<?xml version='1.0' encoding='ASCII' ?> ///<Velocity11 file='MetaData' md5sum='00000000000000000000000000000000' version='1.0' > /// <Command Compiler='0' Editor='2' Name='JS Set Barcode' Description='JS Set plate barcode' > /// <Parameters > /// <Parameter Name='Side' Description='Side on which barcode is present' Scriptable='0' Type='2' > /// <Ranges > /// <Range Value='NORTH' /> /// <Range Value='SOUTH' /> /// <Range Value='EAST' /> /// <Range Value='WEST' /> /// </Ranges> /// </Parameter> /// <Parameter Name='Barcode' Description='Value of barcode to be set' Scriptable='1' Type='1' /> /// </Parameters> /// </Command> ///</Velocity11> function jsAddin_setBarcode(jsAddin_setBarcode_parameter1, jsAddin_setBarcode_parameter2) { // convert jsAddin_setBarcode_parameter1 text to variable name jsAddin_setBarcode_side = eval(jsAddin_setBarcode_parameter1) // set barcode plate.setBarcode(jsAddin_setBarcode_side, jsAddin_setBarcode_parameter2) } |
The preceding code produces a task shown in the following figure. ![]() |
Example XML block structure |
---|
///<?xml version='1.0' encoding='ASCII' ?> XML declaration ///<Velocity11> Velocity 11 root element /// <Command> Command element describing the task /// <Parameters > Parameters element describing how arguments are displayed and entered /// <Parameter /> Escaped Parameter element describing how 1st argument is entered in task parameters GUI /// <Parameter /> Escaped Parameter element describing how 2nd argument is entered in task parameters GUI /// </Parameters> Close Parameters element /// </Command> Close Command element ///</Velocity11> Close Velocity11 element |
Element | Attribute | Value | Description |
---|---|---|---|
Velocity11 | File | MetaData | Specifies XML structure (in this case, use MetaData) |
md5sum | 32-digit hex number | 128- bit hash value that can be used to verify the integrity of an XML block. Use 32 zeros until md5sum calculated. | |
version | 1.0 | Currently always 1.0. | |
Command | Name | String | Name of task (as seen in VWorks Available Tasks list). |
Description | String | Description of task (as seen under the task in a protocol). | |
Compiler | Bitmask | Compiler options. 0 indicates no compiler action. | |
Editor | Bitmask | Protocol editor options: 0 = disregard (default) 1 = hide if not available 2 = Main protocol editor 4 = Sub-process editor 8 = Startup/cleanup process editor 16 = All editors | |
Parameters | Contains one or more Parameter elements. | ||
Parameter | Name | String | Name of field (parameter). |
Description | String | Description of field (shown in task parameters when field is selected). | |
Category | String | A name used to group two or more Parameter elements. | |
Hide_if | Logical test | When the value of the conditional expression in the Hide_if attribute is true, the parameter field is hidden or made read-only. Example: Hide_if='Variable(Type)!=Const(Table)' The parameter will be hidden if the variable Type (the name of a parameter in the same category) is not equal to the constant (in this case the word Table). | |
Scriptable | Integer (boolean) | Indicates if the parameter field can accept JavaScript in the editing dialog. 0 = not scriptable | |
Style | Integer | How parameter fields are displayed in the task window. 0 = displayed as read/write (default) 1 = displayed as read only 2 = displayed as read only and hidden when hide disabled tasks selected in VWorks options. | |
Parameter | Type | Integer | Describes the type of field displayed 0 = Provides a Boolean check box. 1 = Allows the user to specify a character string. 2 = Provides a drop- down list box. 3 = Provides a drop- down combo box. 4 = Allows the user to specify a device location. 5 = Allows the user to specify a labware or a fixed location. 6 = Allows the user to specify both a location and the labware to use. 7 = Opens the Well Selection dialog box. 8 = Allows the user to specify an integer. 9 = Allows the user to specify a file path. 10 = Provides a labware drop- down list box. 11 = Provides a liquid- class drop- down list box. 12 = Allows the user to specify a decimal fraction. 13 = Allows the user to specify a file path, where the value can be empty. 14 = Allows the user to enter a password and displays a series of asterisks to hide the password string. 15 = Allows the user to specify an IP address. 16 = Allows the user to select a directory. 17 = Allows the user to enter a time in the format hh:mm:ss. 18 = Refers to an object in the JavaScript scripting context. 19 = Allows the user to enter a date. The format depends on the region and language settings. 20 = Allows the user to enter character strings that can wrap onto multiple lines. 21 = Opens the Pipette Technique Editor. 22 = Opens the Head Mode Selector dialog box. 23 = Describes the tip positions of a tip box. 24 = Opens the Field Composer dialog box. 25 = Displays the available hit pick format files. For example, when the user clicks the down arrow in the Format file field of the Hit pick replicate task, the list that is displayed is of this type. |
Parameter | Type | Integer | 26 = Deprecated. Used to show the available analog input names in the device file where the plugin resides. 27 = Deprecated. Used to show the available digital input names in the device file where the plugin resides. 28 = Deprecated. Used to show the available digital output names in the device file where the plugin resides. 29 = Converts a parameter of this type to, and accesses it as, a JavaScript array object. 30 = Allows the user to specify a duration in the format n Days hh:mm:ss. 31 = Displays a multi- line text box. 32 = Opens the color palette that enables the user to change the colors of various dialog box components. |
Ranges | Contains one or more Range elements. | ||
Range | Value | String | When the Parameter Type attribute is 2 or 3 then each Range element and Value attribute describe a menu item that can be selected. When the Parameter Type attribute is 8 or 12 then two Range elements with Value attributes containing integers describe the maximum and minimum possible values. |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Example XML block structure | |
---|---|
///<?xml version='1.0' encoding='ASCII' ?> ///<Velocity11 file='MetaData' md5sum='00000000000000000000000000000000' version='1.0' > /// <Command Compiler='0' Name='JS My Array' Description='JS My Array' Editor='-1' NextTaskToExecute='1' RequiresRefresh='0' TaskRequiresLocation='0' VisibleAvailability='1' > /// <Parameters> /// <Parameter Name='Input' Description='Name of array to send to function' Type='1' /> /// <Parameter Name='Output' Description='Name of array returned from function' Type='1' /> /// </Parameters> /// </Command> ///</Velocity11> function myarray(jsAddin_myarray_input,jsAddin_myarray_output) | |
{ // Assign input data to temp eval("jsAddin_myarray_temp = "+jsAddin_myarray_input) // Transfer temp to output eval(jsAddin_myarray_output+" = jsAddin_myarray_temp") } | ![]() Note: array_one and array_two are the names of the variables you want to interact with. |
![]() |
Example file to generate JS Wrapper task |
---|
///<?xml version='1.0' encoding='ASCII' ?> ///<Velocity11 file='MetaData' md5sum='00000000000000000000000000000000' version='1.0' > /// <Command Compiler='0' Description='JS Import File' Editor='-1' Name='JS Import File' NextTaskToExecute='1' RequiresRefresh='0' TaskRequiresLocation='0' VisibleAvailability='1' > /// <Parameters > /// <Parameter Name='Filename' Description='Filename' Category='File' Scriptable='1' Type='9' /> /// <Parameter Name='Type' Description='Type of file and parsing that will be applied. (Text for a single piece of data, List for data in rows and Table for data in a Grid format (eg CSV).)' Category='Parsing' Type='2' Scriptable='0' Value='Text'> /// <Ranges> /// <Range Value='Text' /> /// <Range Value='List' /> /// <Range Value='Table' /> /// </Ranges> /// </Parameter> /// <Parameter Name='Separator' Description='Separator for Grid file type ' Category='Parsing' Type='2' Scriptable='0' Value=',' Hide_if='Variable(Type)!=Const(Table)' > /// <Ranges> /// <Range Value=',' /> /// <Range Value='TAB' /> /// <Range Value=';' /> /// <Range Value=':' /> /// </Ranges> /// </Parameter> /// <Parameter Name='Ignore header' Description='Ignore header rows in list and grid files.' Category='Parsing' Type='0' Scriptable='1' Hide_if='Variable(Type)==Const(Text)' /> /// <Parameter Name='Rows to ignore' Description='Number of rows to ignore in list and grid files.' Category='Parsing' Type='1' Scriptable='1' Hide_if='Variable(Type)==Const(Text)' /> /// <Parameter Name='Ouput' Description='Javascript variable or array into which data is passed. (For Text this results in a variable (eg x), for List this results in an array (eg x[row]) and for Table this results in a 2D array (eg x[row][column]).)' Category='Output' Type='1' /> /// </Parameters> /// </Command> ///</Velocity11> |
Function jsAddin_ImportFile(jsAddin_ImportFile_filename,jsAddin_ImportFile_filetype,jsAddin_ImportFile_separator, jsAddin_ImportFile_ignoreheaders,jsAddin_ImportFile_rowstoignore,jsAddin_ImportFile_output) { // create file object jsAddin_ImportFile_fo = new File() // open file jsAddin_ImportFile_fo.Open(jsAddin_ImportFile_filename) // read file into variable contents jsAddin_ImportFile_contents = jsAddin_ImportFile_fo.Read() // close file jsAddin_ImportFile_fo.Close() // Parse contents depending file type/parsing method switch(jsAddin_ImportFile_filetype) { // Text - assumes one value and passes directly to variable jsAddin_ImportFile_temp case "Text": jsAddin_ImportFile_temp = jsAddin_ImportFile_contents break; // List - assumes a list with a single piece of data on each row case "List": jsAddin_ImportFile_temp = jsAddin_ImportFile_contents.split("\n") break; // Table - assumes a tabular data structure in row and columns case "Table": jsAddin_ImportFile_temp = new Array() jsAddin_ImportFile_lines = jsAddin_ImportFile_contents.split("\n") if(jsAddin_ImportFile_ignoreheaders=="1") { jsAddin_ImportFile_start = jsAddin_ImportFile_rowstoignore } else { jsAddin_ImportFile_start = 0 } jsAddin_ImportFile_ii = 0 for(jsAddin_ImportFile_i=jsAddin_ImportFile_start;jsAddin_ImportFile_i<jsAddin_ImportFile_lines.length;jsAddin_ImportFile_i++) { jsAddin_ImportFile_temp[jsAddin_ImportFile_ii]=jsAddin_ImportFile_lines[jsAddin_ImportFile_i].split(jsAddin_ImportFile_separator) jsAddin_ImportFile_ii++ } break; } // assign jsAddin_ImportFile_temp to output variable eval(jsAddin_ImportFile_output +" = jsAddin_ImportFile_temp") } |
Example of using global script file | |
---|---|
In this example, both the JavaScript tasks contain the same code, as shown in the Task Parameters area. ![]() | |
Global script file ![]() | The function get_date_time(), which is part of the global script file is available both before and after the execution of the JS Wrapper task (JS Set plate barcode). The function jsAddin_setBarcode(), which is part of the JS Wrapper task (JS Set plate barcode), is only available after the JS Wrapper task is executed. |
Sequence of events displayed in Main log ![]() |
Example of JS Wrapper file to enable Global script file |
---|
///<?xml version='1.0' encoding='ASCII' ?> ///<Velocity11 file='MetaData' md5sum='00000000000000000000000000000000' version='1.0' > /// <Command Compiler='0' Editor='16' Name='JS Enable Global Scripts' Description='JS Enable Global Scripts File (jsaddin_global_vars.js)' > /// <Parameters /> /// </Command> ///</Velocity11> function jsAddin_enableGlobalScripts() { print("Global Script File Enabled") } |
For information about... | See... |
---|---|
Using JavaScript in the VWorks software | |
Using script variables directly in task parameters | |
JavaScript task description |