/// <summary> /// Preforms an error check on this script if the use clicks the check errors toolbar strip button. /// </summary> /// <param name="sender">Object that caused this event to be triggered.</param> /// <param name="e">Arguments explaining why this event occured.</param> private void checkSyntaxToolStripButton_Click(object sender, EventArgs e) { // Compile the script. ScriptCompiler compiler = new ScriptCompiler(); bool errorOccured = false; //errorListView.Items.Clear(); CompileFlags flags = 0; if (Path.GetExtension(_url.ToString()).ToLower() == ".fsl") { flags |= CompileFlags.Library; } string errors = ""; if (compiler.CompileString(scriptTextBox.Text, flags, _url.ToString()) > 0) { foreach (CompileError error in compiler.ErrorList) { if (error.AlertLevel == ErrorAlertLevel.Error || error.AlertLevel == ErrorAlertLevel.FatalError) { errorOccured = true; } //ListViewItem item = new ListViewItem(); //item.StateImageIndex = error.AlertLevel == ErrorAlertLevel.FatalError ? 2 : (int)error.AlertLevel; //item.SubItems.Add(new ListViewItem.ListViewSubItem(item, ((int)error.ErrorCode).ToString())); //item.SubItems.Add(new ListViewItem.ListViewSubItem(item, error.Line.ToString())); //item.SubItems.Add(new ListViewItem.ListViewSubItem(item, error.Offset.ToString())); //item.SubItems.Add(new ListViewItem.ListViewSubItem(item, error.Message)); //errorListView.Items.Add(item); errors += error.ToString() + "\n\n"; } } if (errorOccured == false) { if (errors == "") { MessageBox.Show("Error check successfull, script contains no syntax or syntantic errors.", "Error Check Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Error check successfull, script contains no syntax or syntantic errors. However if contains the following warnings; \n\n" + errors, "Error Check Successfull", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Script contains " + compiler.ErrorList.Count + " syntax or syntantic errors;\n\n" + errors, "Error Check Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }