Cicode Function Syntax
Note: In the following function syntax example:
- Every placeholder shown inside arrow brackets ( <placeholder> ) should be replaced in any actual code with the value of the item that it describes. The arrow brackets and the word they contain should not be included in the statement, and are shown here only for your information.
- Statements shown between square brackets ( [ ] ) are optional. The square brackets should not be included in the statement, and are shown here only for your information.
Cicode functions have the following syntax:
[ <Scope> ]
[ <ReturnDataType> ]
FUNCTION
<FunctionName> ( <Arguments> )
<Statement> ;
<Statement> ;
<Statement> ;
RETURN <ReturnValue> ;
END
where:
- <Scope> = Scope Statement: optional, PRIVATE or PUBLIC, default PUBLIC, no semicolon. See the section titled Function Scope.
- <ReturnDataType> = Return Data Type Statement: optional and one of INT, REAL, STRING, OBJECT, QUALITY, or TIMESTAMP. No default, no semicolon. If no return type is declared, the function cannot return any data. See the section titled Declaring the Return Data Type.
- FUNCTION = FUNCTION Statement: required, indicates the start of the function, keyword, no semicolon. See the section titled Declaring Functions.
- <FunctionName> = Name statement: required, up to 32 ASCII text characters, case insensitive, no spaces, no reserved words, no default, no semicolon. See the section titled Naming Functions.
- ( <Arguments> ) = Argument statement: surrounding brackets required even if no arguments used, if more than one argument - each need to be separated by a comma, can contain constants or variables of INT or REAL or STRING or QUALITY or TIMESTAMP data type, default can be defined in declaration, can be spread over several lines to aid readability, no semicolon. See the section titled Function Argument Structure.
- <Statement> = Executable Statement: required, one or more executable statements that perform some action in Citect SCADA, often used to manipulate data passed into the function as arguments, semicolon required.
- RETURN = Return Statement: optional, used to instruct Cicode to stop executing the function and return to the calling function, keyword, no semicolon. If a ReturnDataType was specified then the Return Statement should include a ReturnValue.
- <ReturnValue> = Return Value Statement; required if RETURN Statement used in function, need to be either a constant or a variable, the data type need to have been previously declared in the function Return Data Type Statement - or does not return a value, semicolon required. See the section titled Returning Values from Functions.
- END = END Statement: required, indicates the end of the function, keyword, no semicolon. See the section titled Declaring Functions.
See Also
Published June 2018