public bool Run(ScriptProcedure procedure, bool noevent = false) { Clean(); if (procedure == null) { return(true); } _procedure = procedure; try { procedure.Run(); } catch (Exception ex) { if (_error == null && !ExitException.Is(ex)) { throw; } } if (_error == null) { return(true); } if (OnError != null && !noevent) { OnError(_error); } return(false); }
private void Clean() { _error = null; _err_line = 0; _procedure = null; _result = null; }
public ScriptError(Script script, ScriptProcedure procedure, string message) { _script = script; _proc_item = procedure; _message.Append(message.CleanEnd()); if(script != null) _script.Succeed = false; }
public ScriptError(Script script, ScriptProcedure procedure, string message) { _script = script; _proc_item = procedure; _message.Append(message.CleanEnd()); if (script != null) { _script.Succeed = false; } }
private ScriptProcedures ListProcedures(Script script, Regex pattern) { ScriptProcedures procedures = new ScriptProcedures(); foreach (IMSScriptModule msc_module in _scriptcontrol.Modules) { ScriptModule module = new ScriptModule(msc_module); foreach (IMSScriptProcedure msc_procedure in msc_module.Procedures) { var proc_name = msc_procedure.Name; ScriptProcedure procedure = new ScriptProcedure(module, proc_name); switch (proc_name.ToLower()) { case "initialize": procedures.ProcInitialize = procedure; break; case "terminate": procedures.ProcTerminate = procedure; break; case "setup": procedures.ProcSetup = procedure; break; case "teardown": procedures.ProcTearDown = procedure; break; case "onerror": procedures.ProcOnError = procedure; break; case "iif": break; default: if (msc_procedure.HasReturnValue) continue; if (!pattern.IsMatch(proc_name)) continue; WithParams proc_params_str; if (script.ScriptWithParams.TryGetValue(proc_name, out proc_params_str)) { if (!_scriptcontrol.Eval("Array(" + proc_params_str.Params + ')')) { var error = new ScriptError(script, procedure, "Invalide array: " + proc_params_str.Params); error.AddTrace(script, proc_params_str.Line); OnError(error); continue; } var proc_params = (object[])_scriptcontrol.Result; foreach (var proc_param in proc_params) { object[] args = CastToArray(proc_param); if (args.Length == 0) { var error = new ScriptError(script, procedure, string.Format( "Procedure {0} requires {1} argument(s). {2} provied.", proc_name, msc_procedure.NumArgs, args.Length)); error.AddTrace(script, script.TextFormated.GetLineNumber("(Sub|Function).\b" + proc_name + "\b")); OnError(error); break; } procedure = new ScriptProcedure(module, proc_name, args); procedures.Add(procedure); } } else if (msc_procedure.NumArgs == 0) { procedures.Add(procedure); } break; } } } return procedures; }
public ScriptSuccess(Script script, ScriptProcedure procedure = null) { _script = script; _procedure = procedure; }
private ScriptProcedures ListProcedures(Script script, Regex pattern) { ScriptProcedures procedures = new ScriptProcedures(); foreach (IMSScriptModule msc_module in _scriptcontrol.Modules) { ScriptModule module = new ScriptModule(msc_module); foreach (IMSScriptProcedure msc_procedure in msc_module.Procedures) { var proc_name = msc_procedure.Name; ScriptProcedure procedure = new ScriptProcedure(module, proc_name); switch (proc_name.ToLower()) { case "initialize": procedures.ProcInitialize = procedure; break; case "terminate": procedures.ProcTerminate = procedure; break; case "setup": procedures.ProcSetup = procedure; break; case "teardown": procedures.ProcTearDown = procedure; break; case "onerror": procedures.ProcOnError = procedure; break; case "iif": break; default: if (msc_procedure.HasReturnValue) { continue; } if (!pattern.IsMatch(proc_name)) { continue; } WithParams proc_params_str; if (script.ScriptWithParams.TryGetValue(proc_name, out proc_params_str)) { if (!_scriptcontrol.Eval("Array(" + proc_params_str.Params + ')')) { var error = new ScriptError(script, procedure, "Invalide array: " + proc_params_str.Params); error.AddTrace(script, proc_params_str.Line); OnError(error); continue; } var proc_params = (object[])_scriptcontrol.Result; foreach (var proc_param in proc_params) { object[] args = CastToArray(proc_param); if (args.Length == 0) { var error = new ScriptError(script, procedure, string.Format( "Procedure {0} requires {1} argument(s). {2} provied.", proc_name, msc_procedure.NumArgs, args.Length)); error.AddTrace(script, script.TextFormated.GetLineNumber("(Sub|Function).\b" + proc_name + "\b")); OnError(error); break; } procedure = new ScriptProcedure(module, proc_name, args); procedures.Add(procedure); } } else if (msc_procedure.NumArgs == 0) { procedures.Add(procedure); } break; } } } return(procedures); }
public bool Run(ScriptProcedure procedure, bool noevent = false) { Clean(); if (procedure == null) return true; _procedure = procedure; try { procedure.Run(); } catch (Exception ex) { if (_error == null && !ExitException.Is(ex)) throw; } if (_error == null) return true; if (OnError != null && !noevent) OnError(_error); return false; }