Text Operators
SenseTalk includes several operators that you can use specifically for working with text values.
&
(Ampersand) Operator
Behavior: Creates a text string by combining values one after another. Both operands are converted to text representations if they are not already text before concatenation.
Syntax:
operand1 & operand2
Example:
put "The answer is:" & answer
&&
(Double Ampersand) Operator
Behavior: Joins (concatenates) two values with a space between them. Both operands are converted to text representations if they are not already text before concatenation.
Syntax:
operand1 && operand2
Example:
put "Dear" && correspondent & "," into openingLine
Is In
, Is Contained By
, Is Not In
, Isn't In
Operators
Behavior: Tests for the presence or absence of one value within another, returning true or false.
Ordinarily, this operator is not case-sensitive. To force case-sensitivity, use the considering case
option.
Syntax:
targetValue is {not} in sourceValue {considering case | ignoring case}
targetValue is {not} contained by sourceValue {considering case | ignoring case}
When sourceValue is a list, this operator tests whether any of its values is equal to targetValue. If targetValue is also a list, it tests whether a consecutive sequence of the values in sourceValue are equal to the values in targetValue.
When sourceValue is a range, it is treated the same as a list (as would be generated by converting the range to a list) with the values in that list checked for the presence of targetValue. This is different from the is within
operator which checks whether a value lies anywhere between the start and end values of the range.
When sourceValue is a property list (object), the behavior can be determined by the object itself, or the built-in containsItem
function (see Checking Object Contents for details).
When targetValue is a pattern, defined by using SenseTalk's pattern language, this operator tests whether the pattern matches any substring within the sourceValue.
Otherwise, sourceValue is evaluated as text, and tested to see if it contains targetValue as a substring. To force a substring text search when sourceValue is a list or property list, use the asText
function or as text
operator to convert it to text.
Example:
if "-help" is in commandLine then ...
Example:
if "Johnson" is not in indexList then ...