break case, continue case

Prev Next

Function Names

break case, continue case

Description

break case skips the remaining code till the end of the switch or check block. Even the else statement will be skipped. continue case skips the remaining code inside that case block, then continues checking the next case and else statements.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

0

Examples

for (a[] = 1, a[] <= 5, a[]++)
{
       print ( "Switch Loop ",a[], ":   " );
       switch( a [] )
       {
           case (1)
           {
               print("Case 1; ");
               }
           case (2)
           {
               print("Case 2; ");
               continue case;
           }
           case (3)
           {
               print("Case 3; ");
               break case;
           }
           case (2)
           {
               print("Case 2 again; ");
           }
           case (1,2,3,4)
           {
               print("Case 4; ");
           }
               else
               {
                       print("Else 1; ");
               }
               else
               {
                       print("Else 2; ");
               }
       }
       echo;
}


for (a[] = 1, a[] <= 5, a[]++)
{
       print ( "Check Loop ",a[], ":   " );
       check( a [] )
       {
               case (1)
               {
                       print("Case 1; ");
               }
               case (2)
               {
                       print("Case 2; ");
                       continue case;
               }
               case (3)
               {
                       print("Case 3; ");
                       break case;
        }
               case (2)
               {
                       print("Case 2 again; ");
           }
               case (1,2,3,4)
               {
                       print("Case 4; ");
               }
               else
               {
                       print("Else 1; ");
               }
               else
               {
                       print("Else 2; ");
               }
       }
    echo;
}

Output

Switch Loop 1:   Case 1; Else 2;
Switch Loop 2:   Case 2; Else 2;
Switch Loop 3:   Case 3;
Switch Loop 4:   Case 4; Else 2;
Switch Loop 5:   Else 1; Else 2;
Check Loop 1:   Case 1; Case 4; Else 2;
Check Loop 2:   Case 2; Case 2 again; Case 4; Else 2;
Check Loop 3:   Case 3;
Check Loop 4:   Case 4; Else 2;
Check Loop 5:   Else 1; Else 2;
Try it yourself: Open LIB_Function_break_case.b4p in B4P_Examples.zip. Decompress before use.

See also

switch
check
break
continue
continue with next case