Exit from two loops

In this chapter we are going to learn about the Exit from two loops

Introduction

We can create this program quickly using the Quick Start component

ib_quickstart_exitfromtwoloops.png

Program Steps

After selecting the (Exit from two loops) template, we will get the next steps in the Goal Designer

gd_quickstart_exitfromtwoloops.png

Creating the Program

To create this program we will use the next components

  • For Loop

  • Print Text

  • If Statement

  • Exit

In the begining the Steps Tree is empty

1.png

Select the (For Loop) component

2.png 3.png

The Steps Tree will be updated

4.png

We will create an inner loop (i.e. for loop inside another for loop)

This time, The loop will use the (y) variable

5.png 6.png

We will print the (X) and (Y) values using the (Print Text) component

7.png 8.png 9.png

Using the (If Statement) component, we will check if x=3 and y=5

When this happens, We will end both loops using the (Exit) component

10.png 11.png 12.png 13.png

Select the (Exit) component

14.png

Enter the data in the Interaction Page

Value: 2

This means exit from two loops!

15.png

Now we have the final Steps Tree in our program

16.png