private bool DebugNumberOfParameters()
{
int lineNumber = 1;
foreach (string line in scripts[tabControl1.SelectedIndex].Lines)
{
if (!line.Equals("") && !line.StartsWith("#") && !line.StartsWith("="))
{
string newLine = line;
if (line.Contains(commentString))
{
newLine = Regex.Split(newLine, commentString)[0].TrimEnd();
}
string[] info = newLine.Split(' ');
Command c;
bool success = commands.TryGetValue(info[0].ToUpper(), out c);
if (!success)
{
SuperCommand sc;
success = superCommands.TryGetValue(info[0].ToUpper(), out sc);
if (success)
{
if (info.Length - 1 < sc.NumberOfParameters)
{
MessageBox.Show("Line " + lineNumber + " has too few parameters. Correct number is " + sc.NumberOfParameters);
return false;
}
else if (info.Length - 1 > sc.NumberOfParameters)
{
MessageBox.Show("Line " + lineNumber + " has too many parameters. Correct number is " + sc.NumberOfParameters);
return false;
}
}
else
{
SQLiteConnection con = new SQLiteConnection("Data Source=" + System.Windows.Forms.Application.StartupPath + @"\Data\Commands.sqlite;Version=3;");
con.Open();
SQLiteCommand com = new SQLiteCommand("select * from commands where name = '" + info[0].ToUpper() + "'", con);
SQLiteDataReader reader = com.ExecuteReader();
if (reader != null)
{
c = GetCommand(reader, con);
if (info.Length - 1 < c.NumberOfParameters)
{
MessageBox.Show("Line " + lineNumber + " has too few parameters. Correct number is " + c.NumberOfParameters);
return false;
}
else if (info.Length - 1 > c.NumberOfParameters)
{
MessageBox.Show("Line " + lineNumber + " has too many parameters. Correct number is " + c.NumberOfParameters);
return false;
}
}
else
{
con.Close();
return false;
}
}
}
else
{
if (info.Length - 1 < c.NumberOfParameters)
{
MessageBox.Show("Line " + lineNumber + " has too few parameters. Correct number is " + c.NumberOfParameters);
return false;
}
else if (info.Length - 1 > c.NumberOfParameters)
{
MessageBox.Show("Line " + lineNumber + " has too many parameters. Correct number is " + c.NumberOfParameters);
return false;
}
}
}
lineNumber++;
}
return true;
}