Understanding Native Customs
Keep in mind that on this expedition you will encounter a number of differences specific to SenseTalk. Get familiar with these native customs so you can write scripts with ease!
SenseTalk is a People Oriented Programming language. It aims for familiarity — not for programmers, but for ordinary people. So don't expect %
to be the modulo operator you may have used in other languages — in SenseTalk %
is the percent operator!
SenseTalk is extremely forgiving. For example, requesting an out-of-range value from a list won't throw an exception, it will simply return empty. If a function ends without returning a value, it will return empty. If a call to a command or function supplies fewer parameters than the number declared, the remaining values will receive an initial value of empty. You should be noticing a pattern here. The value empty is a constant whose value is an empty string (the same as "").
Common Idioms
Typically, SenseTalk is written in a conversational style, so the equals
comparison operator is more commonly written using the word is
(or is not
or isn't
for inequality) rather than using the =
(or <>
or ≠
) symbol.
In some cases there are many synonyms for an operator to allow the intent to be expressed in a more natural and meaningful way. For example, is greater than
(or >
) is a natural way to compare numbers, but may be less clear when comparing strings, or dates and times.
put 5 is more than 3
put "c" comes after "a"
put "3:00 PM" is later than "5:00 AM" as time
Comments (to the end of the line) can begin with two dashes or —
(an em-dash) or //
. A hash (#
) is also legal, but isn't considered normal SenseTalk style and is discouraged. Block comments are enclosed in (*
and *)
which may be nested. Block comments using double-asterisks (**
**)
are used by the EggDoc script for generating documentation of scripts and handlers.
Boolean Values
The values true
, false
, yes
, no
, on
and off
are all valid boolean values. True
and false
are constants, the others are treated specially but can technically be used as variables (although such use is highly discouraged unless the meaning is extremely clear within a limited context). Text strings equal to any of the boolean values (such as "YES"
) are also valid in a boolean expression, as is empty (which is treated as false). Numbers (including 0 and 1) are not valid boolean expressions.
The terms yes
, no
, on
and off
are not constants, but are treated specially such that true
, yes
, and on
will all compare as equal to each other, and likewise for the false values. If desired, this behavior can be changed by setting the booleanComparison
global property to "strict" or "lenient" instead of "normal".