Getting out of an IF THEN OR statement

Oct 05, 2020

Is it possible to jump out of a multi IF condition statement once one of the conditions has been satisfied?  For example:

IF x=1 THEN add 1 to x AND perform an action THEN jump out

OR IF x=2 THEN add 1 to x AND perform a different action THEN jump out

OR IF x=3...

If there's no way to jump out of the IF statement then when the first condition is met and x is incremented, the next condition is also met because x was incremented, and all subsequent conditions are met too.  What I want is once one of the conditions are met, the entire IF statement is satisfied, and it stops checking to see if other conditions can also be met - essentially, jumping out of the IF THEN statement until the trigger is initiated again.  Other programming languages us the word "break".  

I hope this isn't too confusing.  Thoughts?

 

 

1 Reply
Sam Hill

Hi Ryan, unfortunately not. The way I have achieved this before is to use a boolean value also to indicate when the condition has been met.

if(conditionmet === false and mycondition === 1) {
conditionmet = true;
  // do your thing
}
if(conditionmet === false and mycondition === 2) {
conditionmet = true;
// do your thing
}
// and so on

Or, if really complex, I'd revert to JavaScript to manipulate a Storyline variable.

This discussion is closed. You can start a new discussion or contact Articulate Support.