Cicode Programming Reference > Using Cicode Commands > Setting Variables

Setting Variables

You can set a Variable in CitectSCADA within a Command field, an Expression field, or in a Cicode Function, by using the mathematical 'equals' sign ( = ) assignment operator. The value on the right is assigned (set) to the variable on the left, as shown in the following Cicode example :

<VAR_TAG> = Val;

where:

<VAR_TAG> is the name of the variable, and Val is the value being assigned to the variable.

Examples

To set a digital variable (named BIT_1) to ON (1), use the command:

BIT_1 = 1;

To set a digital variable (named BIT_1) to OFF (0), use the command:

BIT_1 = 0;

To set a digital variable (named B1_PUMP_101_M) to ON (1), use the command:

B1_PUMP_101_M = 1;

To set a digital variable (named B1_PUMP_101_M) to OFF (0), use the command:

B1_PUMP_101_M = 0;

To set an analog variable (named B1_TIC_101_SP) to a value of ten (10), use the command:

B1_TIC_101_SP = 10;

You can copy a variable to another by assigning (setting) the value of a variable to the value of another variable, for example:

B1_PUMP_101_COUNT = B1_PUMP_101_CLIMIT;

The value of B1_PUMP_101_COUNT is set to the value of B1_PUMP_101_CLIMIT only when that command is issued.

Note: The value of B1_PUMP_101_CLIMIT could change immediately after, but B1_PUMP_101_COUNT remains unchanged and storing the original value, until this command is issued again.