/// <summary> /// Executes the given script. /// </summary> /// <param name="p_strScript">The script code to execute.</param> /// <returns><c>true</c> if the script completes successfully; /// <c>false</c> otherwise.</returns> public bool Execute(string p_strScript) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Control.CheckForIllegalCrossThreadCalls = false; try { ModScriptInterpreter msiInterpreter = new ModScriptInterpreter(m_msfFunctions, p_strScript); return(msiInterpreter.Execute()); } catch (Exception ex) { StringBuilder stbException = new StringBuilder(ex.ToString()); while (ex.InnerException != null) { ex = ex.InnerException; stbException.AppendLine().AppendLine().Append(ex.ToString()); } //string strMessage = "An exception occured in the script."; //m_msfFunctions.ExtendedMessageBox(strMessage, "Error", stbException.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
/// <summary> /// Determines if the given script is valid. /// </summary> /// <param name="p_scpScript">The script to validate.</param> /// <returns><c>true</c> if the given script is valid; /// <c>false</c> otherwise.</returns> public bool ValidateScript(IScript p_scpScript) { ModScriptInterpreter msiScriptCompile = new ModScriptInterpreter(((ModScript)p_scpScript).Code); return(msiScriptCompile.Compile()); }