Пример #1
0
        //Remade without root
        public void setVar(string varName, double varValue)
        {
            //Put Variables in a Dictionary
            if (variables.ContainsKey(varName))
            {
                variables[varName] = varValue;
            }
            else
            {
                variables.Add(varName, varValue);
            }
            //Check if regex is just a variable like "A1" thus root would be a varnode
            opNode sample = new opNode();
            Type   t      = sample.GetType();

            varNode sample2 = new varNode();
            Type    t2      = sample2.GetType();

            if (root.GetType() == t2)
            {
                sample2 = (varNode)root;
                if (sample2.nname == varName)
                {
                    sample2.nnumber = varValue;
                    root.nnumber    = varValue;
                }
                return;
            }
            else if (root.GetType() == t)
            {
                setVarroot((opNode)this.rroot, varName, varValue);
            }
        }
Пример #2
0
        //Inorder search of the varNode type, and after found checking is varName matches
        private void setVarroot(opNode localroot, string varName, double varValue)
        {
            opNode sample = new opNode();
            Type   t      = sample.GetType();

            varNode sample2 = new varNode();
            Type    t2      = sample2.GetType();

            if (!(localroot == null))
            {
                if (t == localroot.lleft.GetType())
                {
                    setVarroot((opNode)localroot.lleft, varName, varValue);
                }
                else
                {
                    if (t2 == localroot.lleft.GetType())
                    {
                        sample2 = (varNode)localroot.lleft;
                        if (sample2.nname == varName)
                        {
                            sample2.nnumber = varValue;
                            //localroot.lleft = sample2;
                        }
                    }
                }
                if (t == localroot.rright.GetType())
                {
                    setVarroot((opNode)localroot.rright, varName, varValue);
                }
                else
                {
                    if (t2 == localroot.rright.GetType())
                    {
                        sample2 = (varNode)localroot.rright;
                        if (sample2.nname == varName)
                        {
                            sample2.nnumber = varValue;
                            //localroot.rright = sample2;
                        }
                    }
                }
            }
        }