Function Call Expressions

Function call expressions are defined using function call syntax.

  • function-name '(' [parameter-list] ')'

Details

Details are as follows:

  • Function call arguments can be passed by value or reference, depending on the function definition.
  • Pass by reference parameters cannot accept literal expressions.
  • Pass by reference parameters cannot cross library boundaries via import library.
  • The return value from a function can be used as an argument for another function.

Examples

The following example illustrates calling a function using literal expressions as arguments. The function TestFunction calls the function AreaOfCircle, passing it a literal argument of 2.0.

double AreaOfCircle( double radius )
{
   return Math.PI() * radius * radius;
}

void TestFunction()
{
   double area = AreaOfCircle( 2.0 );
   Application.Log.LogString( area );
}

The following example illustrates calling a function using literal expressions as arguments as well as one reference argument. The function TestFunction calls the function VolumeOfCube, passing it three literal arguments and one reference argument. The volume of the cube is computed and stored in the reference argument.

void VolumeOfCube( double l, double w, double h, ref double volumeResult )
{
   volumeResult = l * w * h;
}

void TestFunction()
{
   double volume = 0.0;
   VolumeOfCube( 3.0, 4.0, 5.0, volume );
   Application.Log.LogString( volume );
}