public override bool ExecuteAction(ActionProgramRun ap) { if (ap.IsExecuteOn) { 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.PushState(Type, res); // true if has values and true, else false } else { ap.ReportError(errlist); } } else { ap.PushState(Type, ActionProgramRun.ExecState.OffForGood); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) // WHILE at top of loop { if (ap.IsExecuteOn) // if executing { if (condition == null) { condition = new ConditionLists(); if (condition.FromString(UserData) != null) { ap.ReportError("While 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.PushState(Type, res, res); // set execute state, and push position if executing, returning us here when it drop out a level.. } else { ap.ReportError(errlist); } } else { ap.PushState(Type, ActionProgramRun.ExecState.OffForGood); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { if (ap.IsExecuteOn) // if executing { ap.PushState(Type, true, true); // set execute to On (it is on already) and push the position of the DO } else { ap.PushState(Type, ActionProgramRun.ExecState.OffForGood); // push off for good, don't push position since we don't want to loop } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) // LOOP when encountered { if (ap.IsExecuteOn) // if executing { if (!inloop) // if not in a loop { List <string> ctrl = FromString(UserData); List <string> exp; if (ap.functions.ExpandStrings(ctrl, out exp) != ConditionFunctions.ExpandResult.Failed) { if (exp[0].InvariantParse(out loopcount)) { inloop = true; ap.PushState(Type, (loopcount > 0), true); // set execute to On (if loop count is >0) and push the position of the LOOP loopvar = (exp.Count >= 2 && exp[1].Length > 0) ? exp[1] : ("Loop" + ap.ExecLevel); // pick name.. if not given, use backwards compat name ap[loopvar] = "1"; } else { ap.ReportError("Loop count must be an integer"); } } else { ap.ReportError(exp[0]); } } else { ap.ReportError("Internal error - Loop is saying counting when run"); } } else { ap.PushState(Type, ActionProgramRun.ExecState.OffForGood, true); // push off for good and save position so we know which loop we are executing inloop = true; // we are in the loop properly. loopcount = 0; // and with no count } return(true); }