private int DryRunForLength(string name)
{
if (name.StartsWith("@"))
{
List<byte> theScript = new List<byte>();
bool compile = false;
foreach (string line in scripts[tabControl1.SelectedIndex].Lines)
{
if (line.Equals("#org " + name))
{
compile = true;
continue;
}
if (compile)
{
if (!line.Equals("") && !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)
{
DryRunCompileCommand(c, theScript, compile, out compile);
}
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);
DryRunCompileCommand(c, theScript, compile, out compile);
}
else
{
con.Close();
SuperCommand sc;
success = superCommands.TryGetValue(info[0].ToUpper(), out sc);
if (success)
{
switch (info[0].ToUpper())
{
case "FORCETYPE":
{
byte[] stuff = ForceTypeSuperCommand(0);
foreach (byte b in stuff)
{
theScript.Add(b);
}
break;
}
case "PRINTMESSAGE":
{
byte position = 0;
uint locationNew = 0;
foreach (string s in dynamicStrings.Keys)
{
if (s.Equals(info[1]))
{
if (s.StartsWith("@"))
{
locationNew = 0x7FFEFEFE;
}
else
{
bool succeeded = UInt32.TryParse(s, out locationNew);
if (!succeeded)
{
UInt32.TryParse(ToDecimal(s), out locationNew);
}
}
break;
}
position++;
}
byte[] stuff = PrintMessageSuperCommand(position, locationNew, 0);
foreach (byte b in stuff)
{
theScript.Add(b);
}
break;
}
case "SETHALFWORD":
{
byte[] stuff = SetHalfWordSuperCommand(0, 0);
foreach (byte b in stuff)
{
theScript.Add(b);
}
break;
}
case "SETWORD":
{
byte[] stuff = SetWordSuperCommand(0, 0);
foreach (byte b in stuff)
{
theScript.Add(b);
}
break;
}
default:
break;
}
}
}
}
}
else if (line.StartsWith("#"))
{
string[] theLine = line.Split(' ');
switch (theLine[0])
{
case "#org":
compile = false;
break;
default:
break;
}
}
else if (line.Equals(""))
{
compile = false;
break;
}
}
}
return theScript.Count;
}
else
{
return 0;
}
}