Cicode Programming Reference > Writing Functions > Declaring Functions

Declaring Functions

The required FUNCTION Statement follows the optional Scope Statement (if used) and the optional Return Data Type Statement (if used), and precedes any other statements of a function declaration in Cicode. Everything between it and the END Statement, contains the function.

Both FUNCTION and END are Cicode keywords and, as such, are reserved.

You declare the start of a function with the FUNCTION Statement, and declare the end of a function with the END Statement:

<FunctionName> ( <Arguments> )
<Statement> ;
<Statement> ;
<Statement> ;

The FUNCTION Statement needs to be followed by the Name Statement, then the Argument Statement, before any code statements that will be processed by the function.

For information on the Name and Argument Statements, see the sections titled Naming Arguments and Function Argument Structure.

The code (as represented by the <Statement> placeholders) located between the FUNCTION and END Statements, will be executed (processed by the function) when called to do so.

Functions can execute a large variety of statements, and are commonly used to process and manipulate data, including the arguments passed when the function was called, plant-floor and other CitectSCADA data, Windows data, and so on. CitectSCADA provides many built-in functions. For more information, see the section titled Working with Commonly Used Functions.