Skip to main content


Most of the properties of a SenseTalk object are ordinary containers that can store any type of value, and have no special inherent meaning outside of the way they are used in your scripts. There are a few special properties, however, that do affect the way an object is treated by SenseTalk. These include the asText, asTextFormat, objectType, and script properties that show up as ordinary properties of your object but have special meaning. There are also a number of hidden object properties that, although they are not listed by the keys function, they can be accessed and in some cases changed by your script. These include the long id, name, and helpers properties.

Referring to an Object’s Properties

An object’s properties can be accessed in several ways, as described for property lists in Lists and Property Lists. These include the dot (.), apostrophe-S (‘s) and of syntaxes. Ordinary properties are treated as containers – you can store any type of value into them, or modify their values just like those in a variable or other container.

Property and Function Integration: Advanced

Accessing a property of an object and calling a function on an object may seem to be completely different tasks, but in many ways they are quite similar. SenseTalk allows objects to define “property” values using a function that can dynamically calculate the value of the property. To allow the designer of an object complete flexibility in how it is implemented, calling a function on an object and accessing a property look the same in the script that is doing the accessing. To see how this works, consider the following three examples (which are all equivalent):

put gumdrop.color
put gumdrop's color
put the color of gumdrop

Any of these examples will perform the following sequence of actions to determine the value of the expression. First, if gumdrop is an object, a special ‘color’ function message is sent directly to the gumdrop object (note: this message is special because it is not passed through the usual message passing path, but only to the object and its helpers). If the gumdrop object has a to handle color or function color handler, that handler will be called and the value that it returns will be the value of the expression. If it does not handle the color message, then gumdrop’s color property will be accessed instead (including calling getProp or setProp as described below). Finally, if there is no color property (or if gumdrop was not an object), a regular ‘color’ function message is sent with the gumdrop object as a parameter. This message is sent to me, that is, to the object whose script is executing.

Because of this sequence of actions, the gumdrop object’s designer may choose to implement the object’s color using a to handle color or function color handler, a getProp color handler, or an actual color property.

If the word property is used, the property of the object will be accessed without calling the function (but getProp or setProp will still be invoked as appropriate):

put property color of gumdrop -- avoid calling the color function

Parameters may also be passed, but the syntax for doing so is different for function calls or property access:

put gumdrop.color("sprinkles") -- calls the color function
put gumdrop's color("sprinkles")
put the color of gumdrop with "sprinkles" -- unified access
put property color of gumdrop with "sprinkles" -- property

Here, the parameter (the word “sprinkles”) will be passed as a parameter to the color function in the first two examples. The use of parentheses without the word "with" always signifies a function call. The third example (using the "of" syntax) invokes the unified process described above, passing the parameter to the color function, and also to the getProp handler if it is called. If the final step of sending a ‘color’ function message to me is invoked as part of that process, both the gumdrop object and the word “sprinkles” will be passed as parameters.

Multiple parameters may also be passed (always in parentheses):

put gumdrop.color("red", "pink") -- function call
put gumdrop's color("red", "pink")
put the color of gumdrop with ("red", "pink") -- unified
put property color of gumdrop with ("red", "pink") -- property access

Special Properties

There are several object properties with special meaning to SenseTalk. Some of these properties are “hidden” in the sense that they are not listed by the keys or values functions and will not appear in the default text representation of an object, but they can be directly accessed as properties of an object.


Setting an object’s objectType property identifies it as a particular type of object for the is a operator. For example, the object caught by the catch keyword when an exception is thrown has its objectType property set to “exception” so if this object is in a variable named “error” then the expression error is an “exception” would evaluate to true. The objectType property may be set to a list of types if an object may be considered to be of more than one type, as shown here:

set shape to {width:7, height:7, objectType:["rectangle","square"]}
put shape is a "rectangle" --> True
put shape is a "square" --> True

In fact, when the value being tested by the is a operator is an object, SenseTalk sends an “isObjectType” function message to the object, with the type as a parameter. If the object has a to handle isObjectType or function isObjectType handler, it can determine dynamically whether it is an object of the given type and return true or false accordingly. The default SenseTalk implementation of this function checks the objectType property of the object as described above.


The asText property, if set for an object, will be used as the text representation of the object if it doesn’t handle an “asText” function message:

set shape to {objectType:"Square", size:7, asText:"Seven Square"}
put shape --> "Seven Square"


If an object has neither an “asText” function handler nor an asText property, SenseTalk will check for an asTextFormat property. If this property is set for an object, its value will be used as a format string to generate the text representation of the object using the merge() function (see Text and Data Manipulation). This provides a simple way to achieve a dynamic text representation of an object:

set account to {balance:1234.5, type:"Savings", asTextFormat: "[[my type]] Account: [[my balance]]"}
put account --> "Savings Account: 1234.25"
add 5050.50 to account's balance
put account --> "Savings Account: 6284.75"

If an object has neither an "asText" function handler nor an asText nor asTextFormat property, the default representation defined by the propertyListFormat global property will be used.


An object’s script is a property of the object, and may be changed. Setting the script will change the object’s behaviors to those of the handlers in the new script. Handlers that are already executing will not be changed until the next time they are called.

set Fido to {script:<<play "Basso">>}
set the script of Fido to guardDogScript

Helpers, Early Helpers

The helpers and earlyHelpers properties are hidden properties holding lists of objects. When one of these properties is changed, such as by inserting a new helper object, each item in the list is checked to be sure it is an object, and an exception is thrown if it is not. The items in this list are always reported as the objects’ long ids.

Name, Long Name, Short Name, Abbreviated Name, Long ID

The name property, along with its variants long name, short name, or abbreviated name, and the long id property, are all hidden properties that identify the object. All of them except the name property are read-only. For a script file object, the long name and long id are both the full path name of the file on disk, the name and abbreviated name are the file’s name including extension, the short name is the file’s name without the extension if the extension is a recognized script extension in the application.

Folder, Directory

Script file objects also have a folder (or directory) hidden read-only property that provides the full path of the folder where the script file is located.