can anybody explain evaluation of below complex statment in simple way?
-
border.color: ((IsAlarming == false) && (IsAlerting == false)) ? (Name !== "") ? ((!IsCalibrated && IsReCalibratable && (InVivoAdapter.getInvivoParameterAdjusted(Name, modelData.ModelName) === false)) ? (ProfileDetailsAdapter.DarkTheame ? ColorSchemes.blackColorCode : ColorSchemes.grayColorCode3) : (ProfileDetailsAdapter.DarkTheame ? "transparent" : ColorSchemes.grayColorCode3)): "transparent" : measureScreen.getBorderColor(IsAlarming,IsAlerting,AlarmPriority, Value)
i also want to know is there simple way to write this statement ?
-
Hi,
That's an abuse of ternary operator.
Basically: <some_condition> ? execute_if_true : execute_if_false.
You can chain them as shown in your snippet but at that level it's just plain wrong.
You have to rewrite each item on the left of a ? as an if and what's left and right of : as the then and else part of the if.
-
means i need to write it like
if(((IsAlarming == false) && (IsAlerting == false)))
{
if(Name !=="")
{
if(((!IsCalibrated && IsReCalibratable && (InVivoAdapter.getInvivoParameterAdjusted(Name, modelData.ModelName) === false)))
{
if(ProfileDetailsAdapter.DarkTheame)
{
border.color = ColorSchemes.blackColorCode;
}
else
{
border.color =ColorSchemes.grayColorCode3;
}
}
else{
if(ProfileDetailsAdapter.DarkTheame)
{
border.color = "Transparent";
}
else
{
border.color =ColorSchemes.grayColorCode3;
}
}
else
{
border.color = "Transparent";
}
}
else
{
border.color =measureScreen.getBorderColor(IsAlarming,IsAlerting,AlarmPriority, Value);
} -
@Qt-embedded-developer That's the idea yes.