コード例 #1
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            if (ap.IsExecutingType(ActionBase.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);
        }
コード例 #2
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            if (ap.IsExecutingType(ActionBase.ActionType.If))
            {
                if (ap.IsExecuteOff)       // if not executing, check condition
                {
                    if (condition == null)
                    {
                        condition = new ConditionLists();
                        if (condition.Read(UserData) != null)
                        {
                            ap.ReportError("ElseIf 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);
        }