Beispiel #1
0
        // Sets Value to a Valriable in VarList
        public static FVar ML_VariableList(int request, String name, double val)
        {
            if (request == MLGUI.UpdateVariableValue)
            {
                foreach (VariableEntry ve in MLGUI.ML_Variables)
                {
                    if (ve.Name == name)
                    {
                        ve.Variable.SetValue(val);
                        return(ve.Variable);
                    }
                }
            }
            else if (request == MLGUI.AddItem)
            {
                foreach (VariableEntry ve in MLGUI.ML_Variables)
                {
                    if (ve.Name == name)
                    {
                        ve.Variable.SetValue(val);
                        return(ve.Variable);
                    }
                }

                ML_FunctionList(MLGUI.RemoveItem, name);

                FVar newVar = new FVar(name);
                newVar.SetValue(val);
                MLGUI.lastVariableEntry = new VariableEntry(name, newVar);
                MLGUI.ML_Variables.Add(MLGUI.lastVariableEntry);

                return(newVar);
            }
            return(null);
        }
Beispiel #2
0
        public virtual double GetValue(params string[] str)
        {
            // parse and set values

            for (int i = 0; i < str.Length; i++)
            {
                int    w = 0;
                char   c;
                string s   = "";
                int    len = str[i].Length;

                while (w < len)
                {
                    c = str[i][w];
                    if (c == '=')
                    {
                        break;
                    }
                    s = s + char.ToString(c);

                    //System.out.println(str[i] + " // " + s);

                    w++;
                }

                FVar f = FindVariable(s);
                if (f != null && w < len)
                {
                    try
                    {
                        f.SetValue(Convert.ToDouble(str[i].Substring(++w)));
                    }
                    catch (FormatException)
                    {
                    }
                }
            }


            return(rootNode.GetValue());
        }