throw

Prev Next

Function Names

throw

Description

This function discontinues executing and skips executing all further code until the catch() or catch if() function calls or the end program have been encountered. One variable of any valid type (including bigger payloads packed in sets) may be thrown like a frisbee and caught and returned by the corresponding catch functions.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

0 - 1

Parameters

No.TypeDescription
Opt. 1
input
valid types Frisbee value

This value will be returned by the next catch() or catch if() function.

Default value: 0

Examples

       define procedure( foo )
       {
               echo("Test throw");
               throw( "my Frisbee");
               echo("This text does not appear");
       }

       foo;
       echo("This text does not appear, too");
       catch( c[] )
       {
               echo("Caught: ", c[] );
       }
       else: echo("Nothing thrown");

Output

Test throw
Caught: my Frisbee
Try it yourself: Open LIB_Function_throw.b4p in B4P_Examples.zip. Decompress before use.

See also

catch
catch if