Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            SortBlockData sbd = new SortBlockData();

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
Exemplo n.º 2
0
        private int PutFuncToData(int i)
        {
            CalData cd = GetCalDataFromTDC(strFun);

            if (cd != null)
            {
                data [da] = new Data();
                data[da].SetCalData(cd);
                da++;

                string str           = strcal.GetString();
                char   str_Num_Check = str[i - strFun.Length - 1];   //此处还有问题
                if (strcal.CheckNum(str_Num_Check))                  //解决 t=6 2t
                {
                    data[da] = new Data();
                    data[da].SetOption(new Option('*'));
                    da++;
                }
                strFun = "";
                return(i - 1);
            }
            int           k          = 0;
            SortBlockData sortblock2 = new SortBlockData( );
            FuncName      fn         = new FuncName();

            fn.SetFuncName(strFun);
            strFun = "";
            if ((new Calculator()).CheckFunName(fn.GetFuncName()))
            {
                k = strcal.FindBrackets(i + 1);                //只是简单的换个函数就可以实现多重嵌套函数了
                if (k == -1)
                {
                    SortBlockData.error.ErrorMessage += "括号不成对\n";
                    errorMessage += "括号不成对\n";
                    this.Wrong    = true;
                    return(-1);
                }
                string stri = strcal.FromToEnd(i, k - 1);

                //此处应该提取一个专门把函数里面的参数弄出来的类或方法
                CalString str = new CalString(stri);
//				int[] split = str.FindAllElements(new char[]{ ',' });
                int[] split = str.FindOpOutOfBrackets(',');

                split = str.PushToHead <int>(split, -1);
                string[] strsplit = new string[20];                //保存分割后的字符串
                for (int j = 0; j < split.Length - 1; j++)
                {
                    strsplit[j] = str.FromToEnd(split[j], split[j + 1] - 1);
                }

                int count = 0;
                strsplit[split.Length - 1] = str.FromToEnd(split[split.Length - 1], str.GetLength() - 1);



                CalData[] res = new CalData[split.Length];                //保存结果
                foreach (var element in strsplit)
                {
//					Console.WriteLine(element);
                    if (element == null)
                    {
                        break;
                    }
                    CalString     strpart   = new CalString(element);
                    SortBlockData sortblock = new SortBlockData();
                    sortblock.SetCalString(strpart);
                    res[count] = sortblock.GetResult();
                    if (sortblock.Wrong)
                    {
                        sortblock2.Wrong         = true;
                        sortblock2.errorMessage += sortblock.errorMessage;
                    }
                    count++;
                }
                CalData resu = null;
                resu = Calculator.CalFunc(fn.GetFuncName(), res);
                if (sortblock2.Wrong || sortblock2.calculator.Wrong)
                {
                    this.Wrong    = true;
                    errorMessage += sortblock2.errorMessage;
                }
                data [da] = new Data();
                data[da].SetCalData(resu);
                da++;
            }
            else
            {
                stackchop.message.ErrorMessage   += "include unkown characters\n";
                SortBlockData.error.ErrorMessage += fn.GetFuncName().Length > 1?"Include UnKnown 字符串":"Include UnKnown 字符";
                throw new SortBlockException(fn.GetFuncName().Length > 1?"Include UnKnown 字符串":"Include UnKnown 字符" + fn.GetFuncName() + "  还未定义");
                errorMessage += fn.GetFuncName().Length > 1?"Include UnKnown 字符串\n":"Include UnKnown 字符\n";
                Wrong         = true;        //其实这句话可以不要,不要就可以 时间6+你好9=15 而不出错;
                return(i);
            }
            return(k);
        }