Labels in Cicode

In the CitectSCADA help, it states that labels can be used in cicode etc.

What I am trying to do is use partial subsitution to get the values of labels eg

i have a few labels defined:  _C_V01_PressureConstant, _C_V02_PressureConstant etc

i need to perform a partial substitution of the label in cicode where i need to specify the equip name using a string value...

FUNCTION ExampleFunc(string sEquip)

int value = "_C" + sEquip + "_PressureConstant"

//the value returned in 0  but the label has been set a value of 900

END

  • This will not work because labels are evaluated / substituted by the compiler. You cannot combine a label name from parts in runtime.

    You could implement a SELECT CASE statement with all labels spelled in full, for example:

    FUNCTION ExampleFunc(STRING sEquip)

    INT value;

    SELECT CASE sEquip

    CASE "V01"

    value = _C_V01_PressureConstant;

    CASE "V02"

    value = _C_V02_PressureConstant;

    END SELECT

    END

  • In this case you try to assign a string to an integer, which will result into a Hardware Alarm. There are several options:
    - V2016 : Define an extra item (PressureConstant) for your equipment type as Calculated Variable and add a parameter and use this in the Address field
    - V2018 : Put all the constants in a Map using some Cicode, use Equipment as the key name

    You probably want to use these constants somewhere, so in this it becomes easier to reference them.