Boolean Operator Precedence

I have three buttons A, B, and C and want to take specific actions when they are in specific states.

For example, I want to be able to:

Show Layer X

When the user clicks

If A == Normal And ((B == Selected) Or (C==Selected))

Unfortunately, Storyline doesn't allow me to put parenthesis in these expressions. Without parenthesis, And traditionally has higher precedence than Or, right? So my If expression, without parenthesis would evaluate as

If ((A == Normal) And (B == Selected)) Or C==Selected

Can I get the behavior I want with this expression:

If A == Normal And B == Selected Or A == Normal  And C==Selected

Is operator order documented somewhere?

Thanks!

    -Ray

PS: Storyline really needs parenthesis so we can group these conditionals more easily and more clearly.

5 Replies
Michael Sheyahshe

While it doesn't answer your specific question (re: operator documented somewhere), I wonder if you could achieve your desired outcome by adding conditionals to each of the B and C buttons themselves:

If A == Normal (i.e., not selected state), then Show Layer X.

That way, A button state is checked each time B or C is clicked (and thereby, later, in selected state) and, if it's in normal state, show layer X. You could also check that the other one (either B or C) is not in selected state, using AND conditional, if you needed to more specificity.

PS: I agree wholeheartedly - parenthesis is greatly needed in Storyline.

Ray Cole

Hi Michael,

I suppose I could store each intermediate value in a separate variable and, in a series of triggers, put them all together one piece at at time to make sure I get the order I expect, but my example above is simplified from a more complex interaction. Using a laborious work-around like that would be painful.

I'm actually even more confused after doing a bit of testing than I was when I posted my initial post. I wanted to see what Storyline would do with a simple expression like "A or B and C" so I created three True/False variables--A, B, and C--and initialized them all to False.

Then I created a variable to store the result of the expression evaluation: A_or_B_and_C, also initialized to False.

I put 3 checkboxes on the screen and attached a toggle trigger to each one that would toggle its associated variable back and forth between False and True. And I put a second trigger on each checkbox that evaluates the expression "A or B and C" based on whether the toggle is in the selected state or not.

Here's my variables panel:

Variables: A, B, C, and A_or_B_and_C

Here's my screen in its initial state, before I click anything:

Starting screen, before I click anything

Here's my trigger panel:

Trigger panel

I'm basically just displaying the value of the A_or_B_and_C variable via a reference (%A_or_B_and_C%).

When I click the B checkbox, the B variable goes from False to True. Here's how the A_or_B_and_C value changes in response:

B selected

You can see that the reference value changed to True, but I don't see how that can be right.

A == unselected (false)

B == selected (true)

C == unselected (false)

So this amounts to False or True and False.  Suppose Or has higher precedence. Then we'd have to check if (False or True) is true first. It is. Then we'd use that result in the second evaluation:

(False or True) and False

(True) and False

But True And False equals False. So it can't be true that Or has higher precedence than And because my trigger evaluated the original expression to True.

On the other hand, if we assume And has higher precedence, we get this evaluation:

False or (True and False)

But we've already noted that (True and False) equals False, so the full expression evaluates to:

False or (True and False)

False or (False)

Unfortunately, (False or False) also evaluates to False

So how come when I set the checkbox to Selected, the A_or_B_and_C variable evaluates this expression to True? Is there a bug in my triggers?  If there's no bug in the triggers, then this sure seems like a bug in Storyline.

I've attached my *.story file in case anyone wants to take a closer look.

Ray Cole

Walt,

Thanks for the confirmation--I thought I was missing something obvious. I would rank this as a bug that should be a high priority for Articulate to fix.

In fact, I really want two things with respect to trigger logic:

  1. I want the ability to combine And and Or expressions (obviously), ideally with some ability to group the evaluation order (as we'd do on paper with parentheses)
  2. I want the ability to combine actions that share the same conditionals. For example, I want to be able to say ((Change state of A to Hidden) And (Change state of B to Selected) when ...

Sigh. Maybe in Storyline 4?

Cheers!

    -Ray