public override bool ExecuteAction(ActionProgramRun ap) { if (ap.IsExecutingType(Action.ActionType.If)) { if (ap.IsExecuteOff) // if not executing, turn on { ap.ChangeState(true); // go true } else { ap.ChangeState(ActionProgramRun.ExecState.OffForGood); // make sure off for good } } else { ap.ReportError("Else without IF"); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { if (ap.IsExecutingType(Action.ActionType.If)) { if (ap.IsExecuteOff) // if not executing, check condition { if (condition == null) { condition = new ConditionLists(); if (condition.FromString(UserData) != null) { ap.ReportError("IF condition is not correctly formed"); return(true); } } string errlist; bool? condres = condition.CheckAll(ap.functions.vars, out errlist, null, ap.functions); // may return null.. and will return errlist if (errlist == null) { bool res = condres.HasValue && condres.Value; ap.ChangeState(res); // either to ON.. or to OFF, continuing the off } else { ap.ReportError(errlist); } } else { ap.ChangeState(ActionProgramRun.ExecState.OffForGood); // make sure off for good } } else { ap.ReportError("ElseIf without IF"); } return(true); }