void CheckDataType(string Name) { if (tdc.CheckName(Name)) //简单输出显示 变量的值 { CalData datatemp; try { datatemp = tdc.GetData(Name).GetCalData(); } catch (AssignedError e) { PushToShow(e.Message); return; } switch (datatemp.CalType) { case DataType.BLOCK: { BlockData bd = (BlockData)datatemp; PushToShow(bd.ToString()); } break; case DataType.EXP: { ExpData ed = (ExpData)datatemp; try { PushToShow(ed.ToString()); } catch (ExpError e) { PushToShow(e.Message); } break; } case DataType.MATRIX: { Matrix matrix = (Matrix)datatemp; PushToShow(matrix.ToString()); } break; case DataType.FUNC: { FuncData fd = (FuncData)datatemp; PushToShow(fd.ToString()); } break; } } else { var str = SimpleCal(InputData); if (str == null) { PushToShow("No result"); } else { PushToShow(str); } } }
public void Run() { Console.WriteLine("Hello World! type: help() to know how to use"); while (InputData != "exit") { GetDataToInput(); // PushToShow("进入run程序"); funstring.SetString(InputData); int Extype = funstring.AnalyseEquation(); if (Extype == 1 || Extype == 4) //没有等号 判断为命令或求值之类 // PushToShow("不是存值"); { AnalyseInputG(Extype); continue; } //保存起来 string funs = funstring.GetFuncName(); CalData caldata = null; switch (Extype) { case 2: DealAssignment da = new DealAssignment(funstring.GetFuncExpress()); if (tdc.CheckName(funs)) { DataType getdt = new DataType(); try { getdt = da.GetDataType(); } catch (ExpError e) { PushToShow(e.Message); continue; } if (getdt == DataType.EXP) { try { ((ExpData)(da.GetCalData())).GetValueFinal(); //防止循环调用SimpleCal--> ReplaceParamers--> GetValueEx-->SimpleCal } catch (AssignedError e) { PushToShow(e.Message); continue; } } } try { caldata = da.GetCalData(); } catch (AssignedError e) { PushToShow(e.Message); continue; } break; case 3: caldata = new FuncData(funstring.GetFuncExpress(), funstring.GetParamers()); break; default: break; } if (CheckDuplicationName(funs)) { tdc.Remove(tdc.FindPosition(funs)); } if (funstring.CheckFunName(funs)) { PushToShow("Variable Name not acceptable!"); continue; } if (tdc.CreateData(funstring.GetFuncName(), caldata)) { PushToShow("数据已保存"); } else { PushToShow("Not accept input!"); } #region 之前写的不好就改了 // int a = funstring.FindOp(0, '='); // int b = funstring.FindOp(0, '('); // if (a != -1) { // // // if (b > a) { // funstring.AnalyseEquation(); //// funstring.ShowParamers(); // if(CheckDuplicationName()) continue; // // tdc.CreateData(funstring.GetFuncName(), funstring.GetFuncExpress(), funstring.GetParamers()); // } else { // funstring.AnalyseVariable(); //// funstring.ShowParamers(); // if(CheckDuplicationName()) continue; // tdc.CreateData(funstring.GetFuncName(), funstring.GetFuncExpress()); // } // } else { // // } #endregion } }
public function.FuncString ConvertTOFunString() { FuncData fd = (FuncData)Value; return(new function.FuncString(Name, fd.GetExpValue(), fd.GetParamers())); }