Skip to main content
Version: 23.3

Local and Global Properties for Chunk Expressions

Chunk expressions provide a powerful way of handling text data in SenseTalk scripts. The local and global properties described here let you control how chunks are accessed. For additional information about using chunks in SenseTalk, see Chunk Expressions.

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}
note

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 wordDelimiter Local Property, the defaultWordDelimiter Global Property

,

Values: Any character or list of characters, which will serve as separators between words in a container

Default:

  • For the wordDelimiter: The current value of the defaultWordDelimiter global property
  • For the defaultWordDelimiter: Space, Tab, and Return

Behavior: These properties specify the set of characters recognized as separators between words in a container. Any sequence of these characters, in any order or combination, can appear between words.

the wordDelimiter property is local to each handler. Setting its value in one handler doesn't affect its value in other handlers called from that handler, or vice versa. When each handler begins running, the wordDelimiter in that handler is initially set to the value of the defaultWordDelimiter global property.

Example:

set the wordDelimiter to "." // Changes the local word delimiter to period

Example:

put "A man, a plan, a canal. Panama!" into palindrome
put word 4 of palindrome //Returns 'plan,'
set the wordDelimiter to ".,!?;:" & space & tab
put word 4 of palindrome //Returns 'plan'
set the wordDelimiter to ",."
put word 4 of palindrome //Returns ' Panama!'

Example:

set the defaultWordDelimiter to " " // Changes the word delimiter to space across all handlers

Example:

set LookupNumber to "102,311,421.000.631.521"
set the DefaultWordDelimiter to comma&period
set Row to the fifth word of LookupNumber
log Row // Displays '631'
note

You can also specify a delimiter directly in a word chunk expression by including a delimited by clause, as described in Custom Chunks.

Related:

  • the lineDelimiter
  • the itemDelimiter

the wordQuotes Local Property, the defaultWordQuotes Global Property

Values: A list of two values for the beginning and ending quote delimiters, or a single value that will be used as both the beginning and ending delimiters. You can also set it to empty or None to disable word quoting, or to Standard to restore the default quoting.

Default:

  • For the wordQuotes: The current value of the defaultWordQuotes global property
  • For the defaultWordQuotes: Straight double quotation marks

Behavior: These properties specify the quote character or characters used to identify quoted "words" in a word chunk. By default, any word beginning with a double quote character will include all characters up to and including the next double quote character (including any enclosed characters from the wordDelimiter local property).

the wordQuotes property is local to each handler. Setting its value in one handler doesn't affect its value in other handlers called from that handler, or vice versa. When each handler begins running, the wordQuotes in that handler is initially set to the value of the defaultWordQuotes global property.

Example:

set the wordQuotes to "*"

Example:

set Introduction to "Welcome to *The Manor*"
log the third word of Introduction // Displays '*The
set the wordQuotes to "*"
log the third word of Introduction // Displays '*The Manor*'

Example:

set the wordQuotes to empty -- Disable quoting
put "Hi, I'm [[my long name]]" into format
set the wordQuotes to ("[[","]]")
put word 3 of format -- [[my long name]]
set sentence to <<Jack said "Let's go see a movie.">>
put word 3 of sentence -- "Let's go see a movie."
set the wordQuotes to empty -- Disable quoting
put word 3 of sentence -- "Let's

Example:

set the DefaultWordQuotes to none // Disables word quoting

Example:

set Introduction to <<Welcome to "The Manor">>
put word 3 of Introduction // Displays '"The Manor"'
set the DefaultWordQuotes to none
set Introduction to <<Welcome to "The Manor">>
put word 3 of Introduction // Displays '"The'

the lineDelimiter Local Property, the defaultLineDelimiter Global Property

Values: A list of strings that can separate line items when evaluating a line chunk expression. The order of the items in the list is important because they are matched in the order given. For example, to match the common line endings CR, LF, and CRLF, be sure to list CRLF before CR. Otherwise, if CRLF is encountered in text, it will match CR first and be treated as two line endings in a row. Setting the lineDelimiter to empty returns it to the list of standard line endings: CRLF, Return, CarriageReturn, LineSeparator, ParagraphSeparator.

Default:

  • For the lineDelimiter: The current value of the defaultLineDelimiter global property
  • For the defaultLineDelimiter: The list of standard line endings: CRLF, Return, CarriageReturn, LineSeparator, ParagraphSeparator

Behavior: These properties specify the list of delimiter strings recognized as separators between lines of text. You can change the line delimiter to a specific line ending type, such as the Return character (technically, this character is the line feed, LF). This setting works fine for most text that a script interacts with. Text files produced on different platforms (Mac, Windows, Linux) might use other line endings.

To make it easy to work with a variety of files, the lineDelimiter is initially set to a list of standard line endings: CRLF, Return, CarriageReturn, LineSeparator, ParagraphSeparator. If you set the lineDelimiter to a custom list, you can later set it to empty as a shortcut that automatically restores it to the standard list.

You might also want to change the lineDelimiter to take advantage of the fact that it provides a list of delimiters, in order to access chunks of text that might be separated by several different characters.

the lineDelimiter property is local to each handler. Setting its value in one handler doesn't affect its value in other handlers called from that handler, or vice versa. When each handler begins running, the lineDelimiter in that handler is initially set to the value of the defaultLineDelimiter global property.

Example:

set the LineDelimiter to ","

Example:

set stuff to "button" & tab & "paperclip" & tab & "pencil"
set the lineDelimiter to tab
log the second line of stuff // Displays 'paperclip'

Example:

set the lineDelimiter to empty -- Use all standard line endings
put "C:\songs/Solas/BlackAnnis" into songPath
set the lineDelimiter to ("/","\")
put line 2 of songPath -- "songs"

Example:

set the DefaultLineDelimiter to tab

Example:

set stuff to "button" & tab & "paperclip" & tab & "pencil"
set the DefaultLineDelimiter to tab
repeat with each line of stuff
put it
end repeat

The output for the above command would look something like the following:

button
paperclip
pencil
note

You can also specify a list of delimiters directly in a line chunk expression by including a delimited by clause, as described in Custom Chunks.

Related:

  • the wordDelimter
  • the itemDelimiter

the itemDelimiter Local Property, the defaultItemDelimiter Global Property

Values: Typically, a single character

Default:

  • For the itemDelimiter: The current value of the defaultItemDelimiter global property
  • For the defaultItemDelimiter: , (comma)

Behavior: These properties specify the character recognized as the separator between text items in a container. Most often, a single character is used as a delimiter, but it can be set to a longer sequence of characters if desired.

the itemDelimiter property is local to each handler. Setting its value in one handler doesn't affect its value in other handlers called from that handler, or vice versa. When each handler begins running, the itemDelimiter in that handler is initially set to the value of the defaultItemDelimiter global property.

Example:

set the itemDelimiter to "*"

Example:

put "A man, a plan, a canal. Panama!" into palindrome
set the itemDelimiter to "."
put item 2 of palindrome //Displays" Panama!"

Example:

// The following function takes a full file path as input and returns just the directory of the file. It does this by parsing the path into items using "/" as the item delimiter.
function pathOfFile filename
set the itemDelimiter to "/"
delete the last item of filename
return filename
end pathOfFile

Example:

set the DefaultItemDelimiter to "/"

Example:

set the DefaultItemDelimiter to period
log item 2 of "apple.pie" // Displays 'pie'
note

You can also specify a delimiter directly in an item chunk expression by including a delimited by clause, as described in Custom Chunks.

Related:

  • the wordDelimter
  • the lineDelimiter

the characterFiller Global Property

Values: A single character or a string

Default: . (period)

Behavior: This property specifies the behavior when a container is extended by storing into a character chunk that lies beyond the end of the container's contents.

the characterFiller is text that is repeated as needed to fill the container to the desired length. Set it to a single character or to a longer string if desired.

Example:

set the characterFiller to "|"

Example:

put "zig" into test
set the characterFiller to "/\"
put "zag" into character 9 of test
put test -- "zig/\/\/zag"

the lineFiller Global Property

Value: Typically should be a standard line-delimiter character (but technically can be any single character or string)

Default: Return

Behavior: This property specifies the behavior when a container is extended by storing into a line of a chunk that lies beyond the end of the container's contents.

the lineFiller property provides the line delimiter to use when filling a container to the requested number of lines. Typically, it should be set to one of the values listed in the defaultLineDelimiter property. If you use a character or string that is not a line delimiter, the value is inserted the number of times necessary as if to give the correct line; however, in practice this behavior operates similar to the characterFiller property and does not create new lines.

Example:

set the lineFiller to CRLF

Example:

set the lineFiller to "blank line" & return
put "bob" into line 3 of lineVar
put lineVar

Example:

the wordFiller Global Property

Values: A single character or a string, or a list of two values where the second value serves as the word delimiter

Default: ? (question mark character)

Behavior: This properties specify the behavior when a container is extended by storing into a word chunk that lies beyond the end of the container's contents.

the wordFiller can be set to a single value or to a list of two values. When set to a single value, it is a filler word that is repeated as needed to reach the word number being stored into. In this case, the inserted words are separated by the first character of the wordDelimiter property (by default, this value is a Space character). If the wordFiller is set to a list of two values, the first value is the filler word, and the second value is used as the delimiter between inserted words.

Example:

set the wordFiller to period

Example:

set the wordFiller to period
put "10" into countdown
set word 8 of countdown to "9"
log countdown // Displays '10 . . . . . . 9'

Example:

set the wordFiller to "umm..."
put "Hello and" into greeting
set word 5 of greeting to "welcome!"
put greeting -- "Hello and umm... umm... welcome!"