Think of something that you wish Authorware could do but it doesn't?  Let the our good friends at Macromedia know via the wishlist.

Please let us know if you find any of the materials on this site inappropriate or offensive. Please include the url and why the material should be reviewed.

Comments and questions about the site are also welcome. Please no Authorware questions, use the AWARE list.

Back

1078 - How do expression shortcuts work? They look cool, but I don't get it.

by - Joe Ganci


I'm not familiar with shortcuts such as

if Key <> “a” | <> “b”.

Can you clarify what the shortcut is? Does this just apply to Key or to other things as well? And why "<>" instead of "~"?


~ is the NOT operator and it actually changes a value. <> is a relational operator and it compares values.

For instance, if the value of the variable passed equals true, then ~passed equals false. If passed is false, then ~passed is true. Notice I'm not comparing values, I'm changing a logical value to its opposite.

On the other hand,

if passed <> false then....

is comparing the value of score to false. If it is not false, something will happen. This is the same thing as asking if passed is true. Another way would be:

if passed = true then...

This gives the same result. But notice this is the same thing:

if passed then...

Why? Because in reality the if condition simply needs to evaluate to true or false. If the value of passed is already true, our previous example

if passed = true then...

evaluates as:

if true = true then...

Obviously, true is always equal to true (in this universe) so the result will be the same. But this is an extra step. If I wrote:

if passed then...

passed will evaluate to true, so:

if true then...

Again, same result.

What if I want:

if passed = false then...

I can abbreviate the above to:

if ~passed then...

Finally, as to the shortcut, if I want to check a variable for more than one value:

if dice = 7 | dice = 11...

In the above, we want something to happen if the value of the variable dice is either 7 or 11. This can be abbrevieated to:

if dice = 7 | = 11...

You can continue string these along:

if dice = 2 | = 7 | = 11...

If you want to use:

if dice > 2 & dice < 7...

meaning something will happen if the value of dice is 3, 4, 5, or 6, you can abbreviate this as:

if dice > 2 & < 7

Pretty cool, huh?

There are 0 reviews
Add your review
Back