Skip to main content
Version: 23.5

All About “it”

The variable it plays a special role in SenseTalk. There are many situations where a value is provided or used but no specific variable name is specified. In these situations, SenseTalk automatically makes use of the local variable it as the place to store a value. Most of the time, this special role is very convenient, and leads to natural, English-like scripts. However, because quite a few different commands can change it’s value, care must be taken not to assume that it will hold the same value for very long.

To help, here are the commands and constructs that will change the value of it. The following commands always set the value of it, as their normal way of returning a value:

  • answer
  • ask
  • get
  • post

The following commands sometimes set the value of it, depending on how they are used. Generally, if the value passed to one of these commands is a container (such as a variable), the contents of that container are altered directly. If the value passed in is not a container (such as a literal value or an expression), the result is returned in it:

  • add
  • convert
  • divide
  • join
  • multiply
  • read
  • replace
  • reverse
  • shuffle
  • sort
  • split
  • subtract

In addition, the repeat with each command uses it in its simplest form when a specific loop variable is not supplied:

repeat with each... (when no variable is provided)

When any of the commands listed here implicitly set the value of it, they set it to be an ordinary variable, not a reference. If it was previously a reference, it is unlinked from the container it referred to before being set.