Пример #1
0
        public override ValueEval Evaluate(int srcCellRow, int srcCellCol, ValueEval arg0)
        {
            double d;

            try
            {
                ValueEval ve = OperandResolver.GetSingleValue(arg0, srcCellRow, srcCellCol);
                if (ve is BlankEval)
                {
                    return(NumberEval.ZERO);
                }
                if (ve is StringEval)
                {
                    // Note - asymmetric with UnaryMinus
                    // -"hello" Evaluates to #VALUE!
                    // but +"hello" Evaluates to "hello"
                    return(ve);
                }
                d = OperandResolver.CoerceValueToDouble(ve);
            }
            catch (EvaluationException e)
            {
                return(e.GetErrorEval());
            }
            return(new NumberEval(+d));
        }
 /**
  * uses the relevant flags to decode the StringEval
  * @param eval
  */
 private ValueEval XlateRefStringEval(StringEval sve)
 {
     if ((flags & REF_STRING_IS_PARSED) > 0)
     {
         String s = sve.StringValue;
         double d = OperandResolver.ParseDouble(s);
         if (double.IsNaN(d))
         {
             return(ErrorEval.VALUE_INVALID);
         }
         return(new NumberEval(d));
     }
     // strings are blanks
     return(BlankEval.instance);
 }
Пример #3
0
 public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0)
 {
     double d0;
     try
     {
         ValueEval ve = OperandResolver.GetSingleValue(arg0, srcRowIndex, srcColumnIndex);
         d0 = OperandResolver.CoerceValueToDouble(ve);
     }
     catch (EvaluationException e)
     {
         return e.GetErrorEval();
     }
     if (d0 == 0.0)
     { // this '==' matches +0.0 and -0.0
         return NumberEval.ZERO;
     }
     return new NumberEval(d0 / 100);
 }
        public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1)
        {
            ValueEval vA;
            ValueEval vB;

            try
            {
                vA = OperandResolver.GetSingleValue(arg0, srcRowIndex, srcColumnIndex);
                vB = OperandResolver.GetSingleValue(arg1, srcRowIndex, srcColumnIndex);
            }
            catch (EvaluationException e)
            {
                return(e.GetErrorEval());
            }
            int  cmpResult = DoCompare(vA, vB);
            bool result    = ConvertComparisonResult(cmpResult);

            return(BoolEval.ValueOf(result));
        }
Пример #5
0
        public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1)
        {
            ValueEval ve0;
            ValueEval ve1;

            try
            {
                ve0 = OperandResolver.GetSingleValue(arg0, srcRowIndex, srcColumnIndex);
                ve1 = OperandResolver.GetSingleValue(arg1, srcRowIndex, srcColumnIndex);
            }
            catch (EvaluationException e)
            {
                return(e.GetErrorEval());
            }
            StringBuilder sb = new StringBuilder();

            sb.Append(GetText(ve0));
            sb.Append(GetText(ve1));
            return(new StringEval(sb.ToString()));
        }
        /**
         * uses the relevant flags to decode the StringEval
         * @param eval
         */
        private ValueEval XlateStringEval(StringEval eval)
        {
            if ((flags & STRING_IS_PARSED) > 0)
            {
                String s = eval.StringValue;
                double d = OperandResolver.ParseDouble(s);
                if (double.IsNaN(d))
                {
                    return(ErrorEval.VALUE_INVALID);
                }
                return(new NumberEval(d));
            }
            // strings are errors?
            if ((flags & STRING_IS_INVALID_VALUE) > 0)
            {
                return(ErrorEval.VALUE_INVALID);
            }

            // ignore strings
            return(XlateBlankEval(BLANK_IS_PARSED));
        }
        //public int Type
        //{
        //    get
        //    {
        //        // TODO - remove
        //        throw new Exception("obsolete code should not be called");
        //    }
        //}
        protected double SingleOperandEvaluate(ValueEval arg, int srcCellRow, int srcCellCol)
        {
            ValueEval ve = OperandResolver.GetSingleValue(arg, srcCellRow, srcCellCol);

            return(OperandResolver.CoerceValueToDouble(ve));
        }