end

Prev Next

Function Names

end

Description

Program execution will stop. If a numeric parameter is provided, then it will be passed as exit code back to the operating system or calling process or superior B4P program which has started this program using start() or include() functions. The key difference to exit(): Exit will stop B4P in all cases, even if called by a superior B4P program.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

Parameter count

0 - 1

Parameters

No.TypeDescription
Opt. 1
input
numeral Exit code

Default value: 0

Examples

       savecode
       if ( member count(command line arguments[]) == 2 ) // Define function only once
       {
               define procedure( foo )
               {
               echo("Demonstrate ending from here with code 5");
               end(5);
               }
       }

       if (member count(command line arguments[]) == 2)
       {
               echo( command line arguments[1] );
               echo("Calling foo ...");
               foo;
               echo("This text will not appear");
       }

       echo("Start this program recursively");
       rv[] = start( "./REF_Function_end.b4p", "Nesting" );
       echo("Exit code received = ", rv[] );

Output

Start this program recursively
Nesting
Calling foo ...
Demonstrate ending from here with code 5
end (); called
Code execution will end.  Leave or go to superior code.
________________________________________________________________________
Exit code received = 5
Done - Press ENTER key
Try it yourself: Open LIB_Function_end.b4p in B4P_Examples.zip. Decompress before use.

See also

exit