Exit Block

Parent Previous Next

Exit Block.

You can exit a code block using the exit keyword like this:


 {

   Exit Function; //NB! Use Return to exit a value.

   Exit If

   Exit Case

   Exit For

   Exit Repeat

   Exit While

   Exit Try

 }


When used in a code block, which exists on an inner level, the compiler will exit out of one or more code blocks and continue execution on that level, as presented here:


 Function Foo() : Integer

 {

     If True Then

     {

         Repeat

         {

             Case A

             {

               B    { Return 0; }

               C    { Exit Repeat; }

               Else { Exit If; }

             }


         } Until False;


         Return 5;

     }


     Return 10;

 }


In this example Foo will return different results: