private bool DebugCommands()
{
int lineNumber = 1;
foreach (string line in scripts[tabControl1.SelectedIndex].Lines)
{
if (!line.Equals("") && !line.StartsWith("#") && !line.StartsWith("="))
{
if (insideHashOrgBracket)
{
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)
{
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.HasRows)
{
c = GetCommand(reader, con);
}
else
{
con.Close();
MessageBox.Show("The command \"" + info[0] + "\"on line " + lineNumber + " is not recognised as a valid command.");
return false;
}
}
}
}
else
{
string[] info = line.Split(' ');
MessageBox.Show("The command \"" + info[0] + "\" on line " + lineNumber + " is not inside a valid #org compilation area.");
return false;
}
}
else if (line.StartsWith("#org "))
{
uint temp;
if ((line.Split(' ')[1].StartsWith("@") && (line.Split(' ').Length == 2)) || UInt32.TryParse(line.Split(' ')[1], out temp) || UInt32.TryParse(ToDecimal(line.Split(' ')[1]), out temp))
{
insideHashOrgBracket = true;
}
else
{
MessageBox.Show("The script fragment \"" + line.Substring(5) + "\" on line " + lineNumber + " is not a valid pointer. It should be either a 32-bit ROM address or a dynamic pointer beginning with the character \"@\".");
return false;
}
}
lineNumber++;
}
return true;
}