Cicode Programming Reference > Using Variables > Using Variable Scope > Global variables

Global variables

A global Cicode variable can be shared across all Cicode files in the system (as well as across include projects). They cannot be accessed on pages or databases (for example, Alarm.dbf).

Global Cicode variables are prefixed with the keyword GLOBAL, and needs to be declared at the start of the Cicode file. For example:

GLOBAL STRING sDefaultPage = "Mimic";
MyPageDisplay(STRING sPage)
INT iStatus;
iStatus = PageDisplay(sPage);
IF iStatus <> 0 THEN
RETURN iStatus;

The variable sDefaultPage could then be used in any function of any Cicode file in the system.

Note: Use global variables sparingly if at all. If you have many such variables being used by many functions, finding bugs in your program can become time consuming. Use local variables wherever possible. Global Cicode STRING types are only 128 bytes, instead of 256 bytes.