How to evaluate a state table for Boolean Logic evaluation

Hi,
What is good practice to evaluate boolean variables that have come from a complex loop? For example - I have a “while” loop with nested “if” statements. The loop can exit under a variety of conditions and based on how it ended I would like to take differnt actions. This can be accomplished with further “IF-ELSE” statements but this can be hard to follow and troubleshoot later.

What is good practice here? Write to an excel and do the logic there? Use IF-ELSE? Something else I don’t know?

eg:
Case 1 True False False - Take Action 1
Case 2 True True False - Take Action 2
Case 3 True True True - Take Action 3

Where each column is a different Boolean variable.

Just wondering if anybody has advice on this?

I used if-else but as feared it is pretty hard to follow.

I think you should still go with if-else.

Have you tried combining the values of the boolean variables into a string and then using if-else for this string?
So you will need to only use one if-else condition for a case.

Will this work for you?

Thanks, that’s actually a much better way than my implementation - the state table condition is completely clear from the top line of the “IF” statement. That makes it much easier to refer to the documentation and see what you are executing.

1 Like