question

10Dulkar avatar image
0 Likes"
10Dulkar asked 10Dulkar commented

Exit "for loop "

is there a command to exit the For Loop. I am running a code to check something and once found i dont want to continue with the loop, i want to break the look and get out of it to execute next statements. Can anyone suggest the command to get out of the For Loop.

FlexSim 21.2.1
for loop
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jeanette F avatar image
1 Like"
Jeanette F answered 10Dulkar commented

Hello @sachin T3,

You can use an if statement inside of your for loop to check that you found what you were looking for and then have have break written inside of that if statement. This will allow you to break from the loop.

 for (int i; i<5; i++){
      x+=1;
      if (x == 3){
          break;
      }
 }
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

10Dulkar avatar image 10Dulkar commented ·

Thank you Jeanette!


0 Likes 0 ·