Exemplo n.º 1
0
        public override PluginArgs InputText(PluginArgs args)
        {
            if (args.Command.StartsWith("/?"))
            {
                string command = args.Command.Substring(3);
                scriptObject.ExecuteStatement(command);
                args.Command = "";
            }
            else if (args.Command.StartsWith("/!"))
            {
                string command = args.Command.Substring(3);

                if (command.IndexOf(' ') == -1)
                {
                    object[] param = { };
                    RunScript(command, param);
                }
                else
                {
                    //parse the params
                    string ps = command.Split(new char[] { ' ' }, 2)[1];
                    command = command.Split(new char[] { ' ' }, 2)[0];

                    string[] param = ps.Split(new char[] { '|' });
                    object[] p     = new object[param.Length];

                    for (int i = 0; i < param.Length; i++)
                    {
                        System.Diagnostics.Debug.WriteLine(i + ":" + param[i]);
                        //param[i] = (object)param[i];
                        //convert to type Integer if possible
                        int result;
                        if (Int32.TryParse(param[i].ToString(), out result))
                        {
                            //param[i] = (Int32)param[i];
                            p[i] = Convert.ToInt32(param[i]);
                        }
                        else
                        {
                            p[i] = param[i];
                        }
                    }

                    System.Diagnostics.Debug.WriteLine("/! parse:" + command);
                    System.Diagnostics.Debug.WriteLine(p.GetType());
                    System.Diagnostics.Debug.WriteLine(p);

                    RunScript(command, p);
                }
                args.Command = "";
            }
            else
            {
                object[] param = { args.Command };
                RunScript("OUTTEXT", param);
            }
            return(args);
        }