+1 650 396 9674

Function Declarations

To declare a function, specify a return type, name, parameter list, optional attribute list, and function body. In Scenome Scripting Language, a function cannot be declared without also being defined immediately thereafter.

  • data-type function-name '(' [parameter-list] ')' ['['attribute-list']'] function-body


Details are as follows:

  • Forward declarations are currently unsupported.
  • Functions accept parameters by value or reference.
  • Functions cannot implement commands in Scenome, rather they are used internally by other functions or macros.
  • Macros must be used to implement commands in Scenome.


The following example declares a function named ComputeSum, which sums two values and returns the result.

function int ComputeSum( int value1, int value2 )
   return value1 + value2;

The following example declares a function named FormatQuadrantName, which appends two integer values to a string, and returns the result. For Example: "Quadrant 1x2"

function string FormatQuadrantName( string prefix, int quadx, int quady )
   return prefix + " " + quadx + "x" + quady;

The following example declares a function named GetDistance, which calculates the distance between two points.

function double GetDistance( double x1, double y1, double x2, double y2 )
   double dx = x1 - x2;
   double dy = y1 - y2;
   return Math.Sqrt( dx * dx + dy * dy );

Reference parameters are typically used with functions that require more than one output. The following example declares a function named TranslateXY, which translates the first two parameters passed to it by the amount specified in the third parameter. REF parameters cannot cross library boundaries.

function void TranslateXY( ref int x, ref int y, int delta )
   x = x + delta;
   y = y + delta;