Titan



function

1. Declaring a function

2. Declaring an external function

Functions are used to determine test behavior, organize test execution and structure computation. They can be defined within a module or externally; restricted to a component or not. They may have parameters and return a single value.

Related keywords:


1. Declaring a function


function function_identifier ( [ value |timer |template |port  ... ] )[ runs on component_reference ] [ return returned_type ] {statement_block};

Example


2. Declaring an external function


external function function_identifier ( [ value |timer |template |port  ... ] ) [ return returned_type ] ;

Example



Example 1a:

function f_MyF_1 (integer pl_1, boolean pl_2) {};

The function f_MyF_1 has two input parameters (the integer pl_1 and the Boolean pl_2). No value is returned and the function is not restricted to a given component. The statement block is empty.

Example 1b:

function f_MyF_2() return integer { return 28 };

The function f_MyF_2 has no input parameters but an integer value is returned. The function is not restricted to a given component. The statement block is always returns the integer value 28.

Example 1c:

function f_MyF_3() runs on MyCompType_CT {};

The function f_MyF_3 has neither input parameters nor returns any value. The function is not restricted to the component MyCompType_CT. The statement block is empty.

Example 2:

external function f_Utifraan() return float;

The function called f_Utifraan MonConst is defined in an external module, e.g. in a module written in C++. It has no input parameters but returns a floating point value.



BNF definition of function