public static TclObject Tcl_GetVar(Interp interp, string part, VarFlag flags)
 {
     try
     {
         TclObject to = interp.getVar(part, flags);
         return(to);
     }
     catch (Exception e)
     {
         return(TclObj.newInstance(""));
     };
 }
 public static bool Tcl_ObjSetVar2(Interp interp, TclObject toName, TclObject part2, TclObject toValue, VarFlag flags)
 {
     try
     {
         if (part2 == null)
         {
             interp.setVar(toName, toValue, flags);
         }
         else
         {
             interp.setVar(toName.ToString(), part2.ToString(), toValue.ToString(), flags);
         }
         return(false);
     }
     catch { return(true); }
 }
 public static TclObject Tcl_GetVarType(Interp interp, string part1, string part2, VarFlag flags)
 {
     try
     {
         TclObject to = interp.getVar(part1, part2, flags);
         return(to);
     }
     catch { return(null); };
 }
        public static TclObject Tcl_GetVar2Ex(Interp interp, string part1, string part2, VarFlag flags)
        {
            try
            {
                Var[] result = Var.lookupVar(interp, part1, part2, flags, "read", false, true);
                if (result == null)
                {
                    // lookupVar() returns null only if VarFlag.LEAVE_ERR_MSG is
                    // not part of the flags argument, return null in this case.

                    return(null);
                }

                Var       var   = result[0];
                Var       array = result[1];
                TclObject to    = null;

                if (var.isVarScalar() && !var.isVarUndefined())
                {
                    to = (TclObject)var.value;
                    double D = 0;
                    if (!Double.TryParse(to.ToString(), out D))
                    {
                        if (String.IsNullOrEmpty(to.typePtr))
                        {
                            to.typePtr = "string";
                        }
                    }
                    else if (to.ToString().Contains("."))
                    {
                        to.typePtr = "double";
                    }
                    else
                    {
                        to.typePtr = "int";
                    }

                    return(to);
                }
                if (var.isSQLITE3_Link())
                {
                    to = (TclObject)var.sqlite3_get();
                }
                return(to);
            }
            catch { return(null); };
        }
        public static TclObject Tcl_GetVar2Ex(Interp interp, string part1, string part2, VarFlag flags)
        {
            try
            {
                Var[] result = Var.lookupVar(interp, part1, part2, flags, "read", false, true);
                if (result == null)
                {
                    // lookupVar() returns null only if VarFlag.LEAVE_ERR_MSG is
                    // not part of the flags argument, return null in this case.

                    return(null);
                }

                Var       var   = result[0];
                Var       array = result[1];
                TclObject to    = null;

                if (var.isVarScalar() && !var.isVarUndefined())
                {
                    to = (TclObject)var.value;
                    //if ( to.typePtr != "String" )
                    //{
                    //  double D = 0;
                    //  if ( !Double.TryParse( to.ToString(), out D ) ) { if ( String.IsNullOrEmpty( to.typePtr ) ) to.typePtr = "string"; }
                    //  else if ( to.typePtr == "ByteArray" )
                    //    to.typePtr = "bytearray";
                    //  else if ( to.ToString().Contains( "." ) )
                    //    to.typePtr = "double";
                    //  else
                    //    to.typePtr = "int";
                    //}
                    return(to);
                }
                else if (var.isSQLITE3_Link())
                {
                    to = (TclObject)var.sqlite3_get();
                }
                else
                {
                    to = TclList.newInstance();
                    foreach (string key in ((Hashtable)array.value).Keys)
                    {
                        Var s = (Var)((Hashtable)array.value)[key];
                        if (s.value != null)
                        {
                            TclList.append(null, to, TclString.newInstance(s.value.ToString()));
                        }
                    }
                }
                return(to);
            }
            catch (Exception e)
            {
                return(null);
            };
        }