And/Or Statements
It is possible that some scripts may require a while or If condition that requires multiple values to be evaluated. This situation can normally be handled by nesting If or while statements within each other, but this approach can be hard to follow and often leads to duplicating Steps to handle all the situations.
There are two Features in CycleScript to assist with complex decisions: And statements and Executing Scenarios.
And statement
Cycle allows many Steps to be used as a conditional Step. The Steps within a multi-Step conditional Step must be separated by an AND. When evaluating a multi-Step conditional Step, Cycle will run the Steps one at a time. If any Step fails, Cycle does not run subsequent Steps within the conditional Step. If all the Steps pass, the Steps within the if or while statements are run.
The Scenario below shows Cycle prompting the user for two pieces of information. The script will look at the two values entered and scan the screen for an image to determine if the user is or is not a Carolina Panthers fan. If all three Steps pass, then the Step in the if statement is executed; otherwise, the conditional Step fails and the Step in the else statement is run.
Or statement
There are situations in which you may need an if/while decision to look at multiple conditions and pass if any of the conditions are true. In a classic programming language, this logic would be addressed with an or statement. Cycle does not support the use of an or statement, however the same functionality can be achieved by calling another Scenario in the conditional Step using the I execute scenario Step. In the figure below, the Feature calls Scenario North or South Carolina so that the if statement passes for either SC or NC.