public async Task CheckLine(string line, int linePos, FireType type) { try { if (line != "" && !line.StartsWith("//")) { line = line.Replace(",", "").Trim(); line = line.ToLower().Replace("x", "0"); ScriptCommand sendCom = new ScriptCommand(null, new byte[] { 0, 0, 0, 0 }, null, 0); if (line.Length == 20) { sendCom = new ScriptCommand(new string[] { "" }, Tools.ConvertMsgToByte(line), "", 0); } else { uint adr = 0; Invoke((MethodInvoker) delegate { adr = Tools.MakeAdr(); }); sendCom = await CustomScriptCommands.CheckForCommands(line, adr, true).ConfigureAwait(false); if (sendCom.codeContent == noCommand) { sendCom = new ScriptCommand(new string[] { "" }, MakeCommand(line), "", 0); } } if (sendCom == null || sendCom.codeContent == null || sendCom.custom) { if ((sendCom == null || sendCom.codeContent == null) && !sendCom.custom) { MainForm.m.WriteToResponses(line + " is invalid!", true); } else if (sendCom.codeContent == loop) { int val = CustomScriptCommands.CheckForVal(line); if (val > 0) { loopPos = linePos; loopAmount = val; } } else if (sendCom.codeContent == loopStop) { if (loopPos != -1) { currentLoops++; } loopNow = true; } if (sendCom != null && !sendCom.custom) { Console.WriteLine("null command"); } return; } if (type == FireType.IP) { await IPSend(sendCom, line); } else { //SerialSend(send, line); } } } catch (Exception e) { MainForm.m.WriteToResponses("Failed to parse line! (" + line + ")\n" + e.ToString() , false); } }
private void b_Debug_Click(object sender, EventArgs e) { sc = CustomScriptCommands.CheckForCommands(tB_Debug.Text, 0, false).Result; Tools.ShowScriptCommandInfo(sc, true); }