A function in Cicode can be described as a collection or list of sequential statements that CitectSCADA can perform (execute) in the logical order that they exist within the function.
A Cicode function starts with the FUNCTION statement and finishes with the END statement. Every statement that lie between the FUNCTION and END statements, will be executed by the function, when called to do so.
A typical Cicode function is structured like the following example:
FUNCTION
FunctionName ( )
! The exclamation point indicates that the rest of this line contains a comment.
! Further Cicode statements go here, between the function name and the END.
END
The line immediately following the FUNCTION statement, contains the name of the function, which is used to identify the function to CitectSCADA. This name is referred to when the function is called upon (called) to be executed (perform the statements it contains) by some other event, action, or function in CitectSCADA.
Note: Functions can contain statements that call other functions. These functions are then executed before returning to the rest of the statements within the calling function.
The function name has to end with parentheses ( ), which may or may not contain one or more arguments required by the function. Arguments are explained in the section titled Function Argument Structure.
Every line between the function name line and the END statement line contain the statements that will be executed when the function is called in CitectSCADA. These statements are executed one at a time in logical order from top to bottom within the function. For details about function structure, see Formatting Functions. For details about Cicode function syntax, see Following Cicode Syntax.
For details about using comments in Cicode and in Cicode functions, see Using Comments in Cicode.