break, continue

Prev Next

Function Names

break, continue

Description

break breaks switch and check blocks or loops, whichever is closer.
continue continues switch and check blocks or loops, whatever is closer.
See also:

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

0

Examples

echo("Break and continue loops");
for (a[] = 1, a[] <= 4, a[]++)
{
       echo("  Loop begin ", a[] );
       if (a[] = 2) continue;
       if (a[] = 3) break;
       echo("  Loop end ", a[] );
}

echo("Break and continue cases");
for (a[] = 1, a[] <= 4, a[]++)
{
       echo("  Loop begin ", a[] );
       switch(a[])
       {
               case (2) break; // Breaks case only
               case (3)
               {
               repeat(5, b[])
               {
                       echo("Inner loop: ", b[]);
                       if (b[]==2) break; // Break the inner loop
               }
               echo("Inner loop done");
               }
       }

}

Output

Break and continue loops
  Loop begin 1
  Loop end 1
  Loop begin 2
  Loop begin 3
Break and continue cases
  Loop begin 1
  Loop begin 2
  Loop begin 3
Inner loop: # Invalid Value #
Inner loop: 1
Inner loop: 2
Inner loop done
  Loop begin 4
Try it yourself: Open LIB_Function_break.b4p in B4P_Examples.zip. Decompress before use.

See also

break loop
continue loop
break case
continue case
switch
check