Global Properties for SenseTalk Variables
SenseTalk includes several global properties that let you control how you can access and work with variables in your scripts.
For information about working with variables in SenseTalk, see Variables.
You can set a global property value with the SenseTalk commands Set or Put. Note that when you reference one of these properties, you must use the word the before the property name to distinguish it from an ordinary variable.
Examples:
set the searchrectangle to [1,2,2,3]
put 2 into the remoteworkinterval
You can add or change specific named properties within a global property like this:
set the namedColors.pink to color("RGB,1.0,0.5,0.5") -- Adds pink to the namedColors global property and defines its RGB color value
set the listFormat's separator to " & " -- Sets the separator property of the listFormat global property
Properties can also be set or updated by using the setoption or setoptions commands. The setoption command lets you update a single property, and setoptions lets you update multiple properties.
Examples:
setoption searchrectangle, [1,2,2,3]
setoptions {searchrectangle: [1,2,2,3], scriptlogging: yes}
For additional information about working with local and global properties, see Local and Global Properties in SenseTalk.
Related Global Property
SenseTalk includes a related global property as part of the properties that are specific to working with scripts in Eggplant Functionall. the suiteVariables property lets you set or modify suite-wide variables that act as predefined local variables. For complete information about the suiteVariables, see Eggplant Functional Global Properties.
the predefinedVariables Global Property
Values: A property list containing definitions of variables
Default: For a list of current predefined variables, see Predefined Variables Provided or run the following command:
put the predefinedVariables
Behavior: This property is a property list containing the definitions of all the predefined variables. Any changes made to this property affect any subsequent use of an unassigned variable whose name is one of its keys. By modifying this property, predefined variables can be created or removed during a run, or their value can be changed.
Example:
set the predefinedVariables.twelve to "⓬"
put twelve // ⓬
Example:
log checkMark repeated 5 times // Logs '✓✓✓✓✓'
set the predefinedVariables's checkMark to "☑"
log checkMark repeated 5 times // Logs '☑☑☑☑☑'
the evaluationContext Global Property
Values: Local, Global, Universal
Default: Local
Behavior: This property determines the scope of variables in do, send, value(), and merge() expressions. Local variables have the context of a single handler in a script. Global variables can be referenced from any handler within a project, and they retain their value between different handlers. Universal variables retain their values between runs during an entire session.
Example:
set the evaluationContext to "global"
Example:
set global myName to "Carrie"
put merge("My name is [[myName]]") // Displays 'My name is myName'
set the evaluationContext to "global"
put merge("My name is [[myName]]") // Displays 'My name is Carrie'
the strictVariables Global Property
Values: True, False
Default: False
Behavior: This property lets you set a rigorous evaluation of undeclared local variables. With the default value of False, attempting to access an undeclared or unused variable treats it as an unquoted literal (that is, the value of the variable initially is the same as the name of the variable). If you set the strictVariables to True, any attempt to access a variable that has not been explicitly declared or assigned a value throws an exception rather than returning the variable’s name.
Example:
set the strictVariables to true
Example:
log SUTName // Logs 'SUTName'
log BrowserName // Logs 'BrowserName'
set the StrictVariables to true
log SUTName // Throws exception 'StrictVariablesViolation Variable 'SUTName' used without being set'
Example:
set the StrictVariables to true
set SUTName to "WindowsVM"
Connect SUTNme // Throws an exception; helpful for finding typos in variable names
Related: