I have found that I return to the Help section, "Using Variables, Functions, Xtras, and More > How Authorware evaluates expressions," over and over. Because Authorware does not use strict variable types (a variable can contain 1, then "a", then ["cat", "dog", "horse"]), sometimes it does not evaluate your expressions exactly as you might think.
By knowing exactly how expressions do evaluate, you can save yourself
a lot of hassle. You can even use Authorware's
oddities creatively. For instance, this week on
the Aware List, someone had a problem with
the expression "My string containing the number
2." <> 2. This is because Authorware saw a number
on one side of the operator, and so only looked
at the number. The Help file says it like this:
If you use a character string (or character string variable) in a mathematical expression, Authorware interprets the variable as a numerical value. If the character string begins with a number, Authorware extracts the number.
Another little known quirk is that Authorware interprets the strings "T", "On", "True", and "Yes" as the Boolean True. I like to use icon titles to set variables, and I find it much easier to read "Turn MyButton on" than "MyButton = 1". The contents of a calc entitled "Turn MyButton on" might read something like MyButton := GetWord(WordCount(Icontitle), Icontitle). I can use copies of the icon throughout the piece, turning the button on and off by simply changing the last word of the icon's title.
Note that the variable will still contain the value "on" or "off." Even though Authorware evaluates the variable as if it were a 0 or a 1, it still contains the string you assigned to it. If you want it to contain a 0 or a 1 from reading in the icon title, you would wrap the Getword expression in Eval().