Local and Global Properties for Lists and Property Lists
The SenseTalk global and local properties described here control behaviors of lists and property lists in your scripts. You can set or change these options to affect formatting, insertion methods, and other actions to customize your environment.
For complete information about lists and property lists in SenseTalk, see Lists and Property Lists.
Setting or Changing Local and Global Property Values
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}
Because setoption
and setoptions
are specific for use with global and local properties, you omit the word the
from the property name in the command syntax for these commands.
For additional information about working with local and global properties, see Local and Global Properties in SenseTalk.
the listFormat
Global Property
Values: A property list including three required values, and optionally two additional values:
prefix
: The character that precedes the list when converted to text.separator
: The character that appears between each item of the list when converted to text.suffix
: The character that ends the list when converted to textquotes
(optional): This property defines the manner in which values in the list are quoted. By default, thequotes
value is set to "Auto". Seethe defaultQuoteFormat
global property for other options.indent
(optional): This property can be set to a text value that will be used for indenting items in the list. If you set anindent
value, individual list items are displayed on separate lines with values indented by multiples of the indent value, according to the nesting of the structure.
Default: Only the three required values and quotes are set initially:
prefix
: "["separator
: ","suffix
: "]"quotes
: "Auto"
Behavior: This global property defines the format used to convert a list into a text format. When displaying a list as text, the list is surrounded by the prefix and suffix values, with the separator value used between each item of the list.
Predefined values for the listFormat
include boxListFormat
, jsonListFormat
, and standardListFormat
.
Example:
set the ListFormat's separator to period // Uses the 'period' keyword to set the ListFormat's separator to "."
Example:
set the listFormat's quotes to "^"
put ["cheese","meat","fruit"] // Displays '[^cheese^,^meat^,^fruit^]'
Example:
set the listformat to {separator:";"}
put ["cheese","meat","fruit"] // Displays 'cheese;meat;fruit'
Example:
set the ListFormat.prefix to "-->"
put ["cheese","meat","fruit"] // Displays '-->cheese,meat,fruit]'
Example:
set the ListFormat to {separator:";",quotes:"^"}
put ["cheese","meat","fruit"] //Displays '^cheese^;^meat^;^fruit^'
Example:
set the listformat to boxListFormat
put (1,2,3,5,7) // Displays 【1】 【2】 【3】 【5】 【7】
Example:
set the listformat to jsonListFormat
put (1,2,3,5,7)
The output from the above example would display in the Run window as follows:
[
1,
2,
3,
5,
7
]
Example:
set the listFormat.prefix to "[["
set the listFormat's suffix to "]]"
put [1,2,3,4] // Displays '[[1,2,3,4]]'
set the listFormat's separator to " & "
set the listFormat's quotes to ["<",">"]
put [5,6,7,8] // Displays '[[<5> & <6> & <7> & <8>]]'
set the listFormat's indent to " "
put [1,[10,20,30],2]
The final put
command from this example would display in the Run window as follows:
[[
<1> &
[[
<10> &
<20> &
<30>
]] &
<2>
]]
Example:
set the listformat to standardListFormat
put [1,2,3,5,7] //Displays '[1,2,3,5,7]'
Related:
- The
split by
andjoined by
operators, described in Miscellaneous Operators, provide ways to explicitly convert text to lists and vice versa. For more information about working with lists, see Lists and Property Lists. the DefaultQuoteFormat
Global Property
the propertyListFormat
Global Property
Values: A property list that can contain these property values:
prefix
: The character that precedes the list when converted to text.entrySeparator
: The character that appears between each key/value pair of the list when converted to text.keySeparator
: The character that appears between a key and its value when converted to text.suffix
: The character that ends the list when converted to text.quotes
: The character or characters used to quote property values when converted to text, or one of "None", "Standard" or "Auto" (the default). Seethe defaultQuoteFormat
global property for a full description.emptyRepresentation
: The character or characters used if the object has no properties when it is converted to text.indent
(optional): This property can be set to a text value that will be used for indenting items in the list. If you set anindent
value, individual list items are displayed on separate lines with values indented by multiples of the indent value, according to the nesting of the structure.asTextEnabled
:True
,False
Default: See the Behavior section below.
prefix
: {entrySeparator
: ", " (comma and space)keySeparator
: :suffix
: }quotes
:Auto
emptyRepresentation
: {:}asTextEnabled
:True
Behavior: This global property defines the format used when converting a property list (object) into text.
If asTextEnabled
is True
(the default) when the text representation of an object is needed, the object is sent an asText
function message to get its text representation. If the object does not respond to this message, its asText
or asTextFormat
property is used to obtain a text representation.
If asTextEnabled
is False
, or if none of the asText
mechanisms yield a value, then the other values are used. In that case, the object's properties are listed (in alphabetical order of its keys) with each key (property name) preceding its value separated by the keySeparator
(with a default value of ":") and the entries separated by the entrySeparator
(which defaults to ", ").
Property values are quoted according to the quotes
value (which defaults to Standard
for property lists; see the defaultQuoteFormat
global property). The entire text is surrounded by the prefix
and suffix
(default values " and " ). If the object has no properties, the value of the emptyRepresentation
property (default "{:}" ) is used as its text representation.
If the keySeparator
is set to empty, the object's keys are not listed, only its values.
The indent
value can be set to a text value that will be used for indenting entries in the object. When set to anything other than empty, each entry is displayed on a separate line with each line indented by multiples of the indent value, according to the nesting of the structure.
Example:
set the propertyListFormat's entrySeparator to "*"
Example:
set the propertyListFormat's keySeparator to "%"
put {Capitol:"Lansing",Bird:"robin"} // Displays '[Bird%"robin", Capitol%"Lansing"]'
Example:
set the propertyListFormat to {entrySeparator:";"} // The keySeparator is empty, so only the values are displayed
put {Capitol:"Lansing",Bird:"robin"} // Displays 'robin;Lansing'
Example:
put {astext:"Michigan",Capitol:"Lansing",Bird:"robin"} // Displays 'Michigan'
set the propertyListFormat.asTextEnabled to false
put {astext:"Michigan",Capitol:"Lansing",Bird:"robin"} // Displays '{astext:"Michigan", Bird:"robin", Capitol:"Lansing"}'
Example:
set the propertyListFormat to {entrySeparator:"$",keySeparator:"*"}
put {Capitol:"Lansing",Bird:"robin"} // Displays 'Bird*robin$Capitol*Lansing'