private List <JongLocalVariable> localvariablelist           = new List <JongLocalVariable>();                // list with local function variables (used during function assignment)

        public static String FuncToString(JongFunction func, String strSpaceIndent, String strLineIndent, JongErrWarn errW)
        {
            try
            {
                String retStr = "";
                if (func.name() == "Value")
                {
                    retStr += func.eval();
                }
                else if (func.name() == "VariableGet")
                {
                    retStr += ((JongVariableGet)func).getName();
                }
                else if (func.name() == "VariableAssign")
                {
                    retStr += ((JongVariableAssign)func).getName();
                    retStr += " = ";
                }
                else
                {
                    retStr += func.name();
                }

                List <JongFunction> argFuncs = func.get();

                String nextSpaceIndent = (strSpaceIndent + strSpaceIndent);

                foreach (JongFunction argFunc in argFuncs)
                {
                    retStr += "\n";
                    retStr += (strSpaceIndent + strLineIndent);

                    String subStr = FuncToString(argFunc, nextSpaceIndent, strLineIndent, errW);
                    retStr += subStr;
                }

                return(retStr);
            }
            catch (JongError err)
            {
                errW.Init(ErrWStat.UNKNOWN_ERROR, err.get(), false);
                return("");
            }
        }
        /**
         * Parse the given expression
         * @param new_expr   A string containing an expression, for example "2+3"
         * @return ans       A string containing the answer, or an error when
         *                   an error occurred
         */
        public String ParseAndEval(String new_expr, ICheckModelName checkModelName, JongErrWarn errW)
        {
            try
            {
                _checkModelName = checkModelName;

                // initialize all variables
                expr = new_expr;
                ans  = 0.0;

                // Pare the expression into a function tree format
                JongFunction function = parse_start();

                String dbgString = FuncToString(function, "    ", "----", errW);
                dbgString += "\n";

                //System.out.print(dbgString);

                // evaluate the expression
                ans = function.eval();


                if (function is JongFunctionAssign)
                {
                    // function assignment
                    JongFunctionAssign fa   = (JongFunctionAssign)function;
                    String             desc = "";
                    desc += fa.getName();
                    desc += "(";
                    for (int i = 0; i < fa.getVariables().Count(); i++)
                    {
                        if (i > 0)
                        {
                            desc += ", ";
                        }
                        desc += fa.getVariables().ElementAt(i).getName();
                    }
                    desc += ")";

                    ans_str = "Function " + desc + " defined";
                }
                else if (function is JongVariableAssign)
                {
                    // variable assignment
                    JongVariableAssign JongVariableAssign = (JongVariableAssign)function;
                    ans_str = string.Format("%s = %g",
                                            JongVariableAssign.getName(),
                                            ans);

                    // add the answer to memory as variable "Ans"
                    variablelist["ANS"] = ans;
                }
                else
                {
                    //DecimalFormat formatter = new DecimalFormat("#.##########");
                    ans_str = string.Format("{0:#.##########}", ans);

                    // add the answer to memory as variable "Ans"
                    variablelist["ANS"] = ans;
                }
            }
            catch (JongError err)
            {
                errW.Init(ErrWStat.UNKNOWN_ERROR, err.get(), false);
                ans_str = err.get();
                expr    = "";
            }

            return(ans_str);
        }