Variables created inside user-defined procedures and user-defined functions, as well as in B4P programs which have been started from other B4P programs using start() or include() functions, will be local variables. Local variables are only visible locally, i.e.
The local variables are not visible if a further procedure, function or B4P program is called.
Variables may be deleted using the delete() function. Local variables will be deleted automatically when leaving (returning from) user-defined
procedures and functions or called programs.
define procedure( foo, { { a, numeral } } )
{
if (a[] < 4) // If a[] exists a local variable, then the local variable will be used preferentially.
{
foo( 4 ); // Recursive call
a[] = 5;
echo( a[] ); // Called 3rd: 5
}
echo( a[] ); // Called 1st and 4th: 4
a[] = 3;
echo( a[] ); // Called 2nd and 5th: 3
}
a[] = 1;
foo( 2 );
echo(a[] ); // Called 6th: 1 (Global variable)
4
3
5
5
3
1