B4P provides means to define your own procedures and functions, assign plausible names for them and call them up like standard B4P functions. Following control flow functions are available to define your own functions:
All three functions expect a block (inside braces) containing the code. Variables created inside are local variables. Parameters are available
as pure input parameters, output parameters, bi-directional I/O parameters, and references to variables so the whole sub-structure containing thee
the members can be accessed. Return values can be provided with the return() function call.
Additional procedure and function names can be defined on the same implementation. The local variable function name[] is visible inside the code block and
can be used to provide distinguished functionality for every additional procedure and function name. For more info, see
Fore more details, see the section on user-defined functions.
define function( hypotenuse, { { x, numeral }, { y, numeral } } )
{
return( sqrt( x[]*x[] + y[]*y[] ) );
}
define procedure( say hello ) { echo("Hello !"); }
say hello;
echo( hypotenuse(3,4) ); // 5
echo( hypotenuse(5,12) ); // 13
echo( hypotenuse(8,15) ); // 17
echo( hypotenuse(1,1) ); // 1.41...
Hello !
5
13
17
1.4142135624