call

Prev Next

Function Names

call

Description

This function calls a B4P function with the function name provided as a string. The 2nd function parameter may contain a set which will then be passed as function parameters to the targeted function. User-defined functions can be referenced here, but no flow-control functions and functions requiring code pieces in their parameters such as table process(), pick if(), etc.

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled
Limited choice of function names, see above

Parameter count

Min. 1

Parameters

No.TypeDescription
1
input
string Function name

The name must refer to an existing B4P or user-defined function.

2
input
set Function parameters

The values in the set will be provided as function parameters to the target function

Return value

TypeDescription
all types Return value

It is the return value as provided by the specified target function

Examples

       define function( diag, { { value 1, numeral }, { value 2, numeral } } )
       {
               return( sqrt( value 1[] * value 1[] + value 2[] * value 2[] ) );
       }

       for all( { diag, sum, product }, function name[]  )
       {
               echo( "Call ", function name[], "(3,4): ", call( function name[], { 3, 4 } ) );
       }

Output

Call diag(3,4): 5
Call sum(3,4): 7
Call product(3,4): 12
Try it yourself: Open LIB_Function_call.b4p in B4P_Examples.zip. Decompress before use.

See also

deep
deepr
define function