Example #1
0
        void Compute(string varresult, string var1, string ac, string var2)
        {         //?????????? ??? ????????
            Variab v1 = toVar(var1);
            Variab v2 = toVar(var2);
            Variab vr = GetVar(varresult);

            if (ac == "+")
            {
                vr.asN = v1.asN + v2.asN;
            }
            if (ac == "-")
            {
                vr.asN = v1.asN - v2.asN;
            }
            if (ac == "*")
            {
                vr.asN = v1.asN * v2.asN;
            }
            if (ac == "/")
            {
                vr.asN = v1.asN / v2.asN;
            }
            if (ac == "^")
            {
                vr.asN = Convert.ToSingle(Math.Exp(v2.asN * Math.Log(v1.asN)));
            }
        }
Example #2
0
        bool compare(string left, string znk, string right)
        {
            Variab lft = new Variab("lft");
            Variab rgt = new Variab("rgt");

            lft = toVar(left);
            rgt = toVar(right);


            float l = lft.asN;
            float r = rgt.asN;

            if (znk == "==")
            {
                if (l == r)
                {
                    return(true);
                }
            }
            if (znk == "!=")
            {
                if (l != r)
                {
                    return(true);
                }
            }
            if (znk == ">")
            {
                if (l > r)
                {
                    return(true);
                }
            }
            if (znk == "<")
            {
                if (l < r)
                {
                    return(true);
                }
            }
            if (znk == ">=")
            {
                if (l >= r)
                {
                    return(true);
                }
            }
            if (znk == "<=")
            {
                if (l <= r)
                {
                    return(true);
                }
            }


            return(false);
        }
Example #3
0
 void AddVar(string iden, string nm, string val)
 {
     if (GetVar(nm) != null)
     {
         return;
     }
     vari      = new Variab(iden);
     vari.name = nm;
     vari.setVal(val);
     vd.vars.Add(vari);
     vari = null;
 }
Example #4
0
        Variab toVar(string val)
        {
            Variab v = new Variab("");

            try{ v.asN = Convert.ToSingle(val); }
            catch {
                if (GetVar(val) != null)
                {
                    v = GetVar(val);
                }
                else
                {
                    v.asT = val;
                }
            }
            return(v);
        }