public override bool ExecuteAction(ActionProgramRun ap) { if (ap.IsExecuteOn) { if (condition == null) { condition = new ConditionLists(); if (condition.Read(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.Read(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) { if (ap.IsExecuteOn) { string macroname, searchterm; if (FromString(UserData, out macroname, out searchterm)) { if (ap.functions.ExpandString(macroname, out expmacroname) == BaseUtils.Functions.ExpandResult.Failed) //Expand out.. and if no errors { ap.ReportError(expmacroname); return(true); } string expsearchterm; if (ap.functions.ExpandString(searchterm, out expsearchterm) == BaseUtils.Functions.ExpandResult.Failed) //Expand out.. and if no errors { ap.ReportError(expmacroname); return(true); } values = new List <String>(); expsearchterm = expsearchterm.RegExWildCardToRegular(); foreach (string key in ap.variables.NameEnumuerable) { if (System.Text.RegularExpressions.Regex.IsMatch(key, expsearchterm)) { values.Add(key); } } ap.PushState(Type, values.Count > 0, true); // set execute to On and push the position of the ForEach count = 0; if (values.Count > 0) { ap[expmacroname] = values[count++]; System.Diagnostics.Debug.WriteLine("First value " + ap[expmacroname]); } } } else { ap.PushState(Type, ActionProgramRun.ExecState.OffForGood, true); values = null; } 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); }