Cicode Programming Reference > Using Cicode Programming Standards > Formatting Functions

Formatting Functions

Cicode functions have up to seven parts: Scope, Type, Keyword, Name, Argument(s), Statement(s), Keyword.

[Scope]

The scope of the function. If the scope is omitted, the function will be Public by default. That is, it will be available to all Cicode files, pages, and CitectSCADA databases (for example, Alarm.dbf). To make a function Private (that is only available within the file in which it is declared), you need to prefix it with the word PRIVATE.

[Type]

The return type of the function. This should be on a separate line.

Keyword

The keyword FUNCTION. This should be on a separate line.

Name

The function name. Function names should follow the Function Naming Standards. This should be on a separate line.

Argument(s)

The argument list. The arguments are separated by commas and they can have default values. The argument list is normally on the same line as the function name but multiple line argument list is also acceptable if it improves readability.

Statement(s)

The statements. Each statement should be on a separate line.

Keyword

The keyword END which marks the end of the function. This should be on a separate line.

Note: Parts contained within square brackets - [ ] - are optional. For example, the scope may be omitted and if so, it will default to Public. Parts contained within greater than & less than signs - < > - should be replaced with the relevant text/value. For example, you would replace <initial value> with an actual value. You would not bracket your value with greater than & less than signs.

For example:

FUNCTION
PlotInit()
<statements>
END
INT
FUNCTION
PlotOpen(STRING sName, INT nMode)
INT hPlot = _BAD_HANDLE;
...
hPlot = .....;
...
RETURN hPlot;
END
PRIVATE
STRING
FUNCTION
WasteInfoName(INT nType, INT nMode)
STRING sName = "Sydney";
...
sName = .....;
...
RETURN sName;
END

See Also

Writing Functions

Using Cicode Functions

Using Cicode Programming Standards