コード例 #1
0
        /// <summary>
        /// Exceutes this macro the specified variables and process command method.
        /// </summary>
        /// <param name="commandProcessor">The command processor.</param>
        public void Execute(Processor commandProcessor)
        {
            try
            {
                for (int position = 0; position < _commands.Count; position++)
                {
                    Command command = _commands[position];

                    if (command is CommandIf)
                    {
                        string[] processed = Command.ProcessParameters(commandProcessor.Variables, command.Parameters);

                        if (CommandIf.Evaluate(processed[0], processed[1], processed[2]))
                        {
                            position = FindLabel(processed[3]);
                        }
                        else if (!String.IsNullOrEmpty(processed[4]))
                        {
                            position = FindLabel(processed[4]);
                        }
                    }
                    else if (command is CommandGotoLabel)
                    {
                        string[] processed = Command.ProcessParameters(commandProcessor.Variables, command.Parameters);

                        position = FindLabel(processed[0]);
                    }
                    else
                    {
                        commandProcessor.Execute(command, false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new MacroExecutionException("Error executing macro", ex);
            }
        }