Interpets and executes the given Mod Script script.
		/// <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 (bool)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>
        /// 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((bool)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);
            }
        }
Exemple #3
0
        /// <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());
        }
		/// <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();
		}