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

Parents
  • 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

Reply
  • 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

Children
No Data