/// <summary> /// reload the code into the controller to refresh the functions /// </summary> private void ReloadCode() { //remove all functions Functions.Clear(); //create new script controller _scriptController = new ScriptControl(); _scriptController.Language = _language.Name; // Objects available in Script _scriptController.AddObject("Repository", _model.Repository); _scriptController.AddObject("EAModel", _model); //Add the actual code. This must be done in a try/catch because a syntax error in the script will result in an exception from AddCode try { //first add the included code string includedCode = IncludeScripts(Code); //then add the included code to the script controller _scriptController.AddCode(includedCode); // set the functions foreach (Procedure procedure in _scriptController.Procedures) { string description = GetDescription(includedCode, procedure); Functions.Add(new ScriptFunction(this, procedure, description)); } } catch (Exception e) { //the addCode didn't work, probably because of a syntax error, or unsupported syntax in the code var iscriptControl = _scriptController as IScriptControl; ErrorMessage = e.Message + " ERROR : " + iscriptControl.Error.Description + " | Line of error: " + iscriptControl.Error.Line + " | Code error: " + iscriptControl.Error.Text; // use only the error message in the Script object //MessageBox.Show("Error in loading code for script " + this.name + ": " + this.errorMessage, "Syntax error in Script"); } }