Applies To:
  • CitectSCADA 1.00 1.01 1.10 1.11 1.20 2.00 2.01

Citect provides many different ways to define variables. Each different way provides different scopes and performance and is discussed in this article. 

First a definition of what scope is. Scope is the view of where the variable can be accessed. For example if you define a variable in the VARIABLE TAG database that variable has global scope. That means you can access that variable anywhere in the Citect system, eg in alarms, trends, reports, cicode and all the animation databases. This type of variable has a wide scope. If you define a variable local to a cicode file then you can only access that variable in that file, this variable has narrow scope.

It is good programming practice to define a variable with the narrowest possible scope. This limits what can modify the variable and usually the smaller the scope the faster the performance.

Citect has the following scopes for variables.

Variable Tags These tags are from the physical plant (PLCs), DISK PLCs or Memory PLCs. They have the widest scope of all and the slowest access time. Variables from physical PLCs depend on the performance of the protocol. DISK PLCs are normally much faster and Memory PLC are faster again.
global cicode These variables are declared in cicode files outside of the functions. These variables are faster than all types of variable tags and their scope is limited to the cicode file they are declared in. These variables are very similar to a Memory PLC while the scope is limited to a single cicode file. These variables are faster than a memory PLC.
local cicode These variables are declared inside cicode functions. They have the narrowest scope and are the fastest to access.