//--------------------------------------------------------------------- public static string RunEstimate(System.Collections.ArrayList Exp) { try { int k = 0, a, b, res; while (Exp.Count > 1) { if (!(("*".Equals(Exp[k])) || ("/".Equals(Exp[k])) || ("+".Equals(Exp[k])) || (("-".Equals(Exp[k])) || ("mod".Equals(Exp[k]))))) { if ("m".Equals(Exp[k]) || ("p".Equals(Exp[k]))) { a = int.Parse(Exp[k - 1].ToString()); if ("p".Equals(Exp[k])) { res = a; } else { res = int.Parse(MathLibrary.IABS(a).ToString()); if (MathLibrary._lastError.Length > 0) { ShowMessege = true; expression = MathLibrary._lastError; return(expression); } } Exp.RemoveAt(k); Exp.RemoveAt(k - 1); Exp.Insert(k - 1, res.ToString()); k -= 1; } k++; } else { try { a = int.Parse(Exp[k - 2].ToString()); b = int.Parse(Exp[k - 1].ToString()); } catch { ShowMessege = true; expression = "error 06"; return(expression); } switch (Exp[k].ToString()) { case "+": res = MathLibrary.Add(a, b); if (MathLibrary._lastError.Length > 0) { ShowMessege = true; expression = MathLibrary._lastError; MathLibrary._lastError = ""; return(expression); } break; case "-": res = MathLibrary.Sub(a, b); if (MathLibrary._lastError.Length > 0) { ShowMessege = true; expression = MathLibrary._lastError; MathLibrary._lastError = ""; return(expression); } break; case "*": res = MathLibrary.Mult(a, b); if (MathLibrary._lastError.Length > 0) { ShowMessege = true; expression = MathLibrary._lastError; MathLibrary._lastError = ""; return(expression); } break; case "/": res = MathLibrary.Div(a, b); if (MathLibrary._lastError.Length > 0) { ShowMessege = true; expression = MathLibrary._lastError; MathLibrary._lastError = ""; return(expression); } break; case "mod": res = MathLibrary.Mod(a, b); if (MathLibrary._lastError.Length > 0) { ShowMessege = true; expression = MathLibrary._lastError; MathLibrary._lastError = ""; return(expression); } break; default: ShowMessege = true; expression = "error 03"; return(expression); } Exp.RemoveAt(k); Exp.RemoveAt(k - 1); Exp.RemoveAt(k - 2); Exp.Insert(k - 2, res.ToString()); k -= 2; } } return(Exp[0].ToString()); } catch { ShowMessege = true; expression = "error 03"; return(expression); } }