Ejemplo n.º 1
0
        private IEnumerable <ACommand> ParseCommands(string allCommands)
        {
            if (string.IsNullOrWhiteSpace(allCommands))
            {
                Logger.DebugLog("no commands");
                yield break;
            }

            allCommands = Static.GPS_tag.Replace(allCommands, Static.GPS_replaceWith);

            string[] commands = allCommands.Split(new char[] { ';', ':' });
            foreach (string cmd in commands)
            {
                if (string.IsNullOrWhiteSpace(cmd))
                {
                    Logger.DebugLog("empty command");
                    continue;
                }

                ACommand apCmd = GetCommand(cmd);
                if (apCmd == null)
                {
                    m_syntaxErrors.AppendLine("No command: \"" + cmd + '"');
                    Logger.DebugLog("No command: \"" + cmd + '"');
                    continue;
                }

                string msg;
                if (!apCmd.SetDisplayString((IMyCubeBlock)m_block, cmd, out msg))
                {
                    m_syntaxErrors.Append("Error with command: \"");
                    m_syntaxErrors.Append(cmd);
                    m_syntaxErrors.Append("\":\n  ");
                    m_syntaxErrors.AppendLine(msg);
                    Logger.DebugLog("Error with command: \"" + cmd + "\":\n  " + msg, Logger.severity.INFO);
                    continue;
                }

                yield return(apCmd);
            }
        }