Lists
Lists and property lists provide two convenient and powerful ways to organize and manipulate data within your scripts. This section presents the key things you must know to fully exploit the power of lists.
For more information about working with lists, see Chunk Expressions, and the control structure discussion in Repeat with Each.
In addition to lists and property lists, SenseTalk provides a hierarchical tree structure, which is described in Using XML and Tree Structures in SenseTalk Scripts.
Creating Lists
Create a list in a script by listing one or more expressions separated by commas and enclosed in square brackets [ ]
. Lists can also be enclosed in parentheses ( )
if the entire list is on a single line. Lists that are enclosed in square brackets may be written across multiple lines by including a line break after any item within the list (this will not work for lists enclosed in parentheses). Using square brackets is recommended as it makes the list syntax clear and consistent, as well as distinct from other script elements.
Syntax:
[ expr { , expr}... ]
( expr { , expr}... )
{ expr { , expr}... }
[ ]
{an} empty list
Prior to SenseTalk 2.00 (Eggplant Functional 20.1), both lists and property lists used parentheses () by default instead of square brackets [] or curly braces (respectively). Parentheses are still considered valid syntax for lists, but their use is not recommended as it can lead to confusion.
Example:
put [1,3,5,7,9] into oddList
Example:
put [["dog", "Fido"], ["cat", "Cleo"]] into nestedList // Creates a list of lists
Example:
set myList to ["sandwich",49,the date]
Example:
set TestEnvironments = ["Windows","MacOSX","Android","iOS"]