This commit is contained in:
Denis Molony 2017-03-16 20:58:48 +11:00
parent 4819ae2316
commit 814b611915

View File

@ -2,27 +2,6 @@ package com.bytezone.diskbrowser.visicalc;
import java.util.Iterator;
// http://www.bricklin.com/history/refcard1.htm
// Functions:
// @AVERAGE
// @NPV
// @LOOKUP(v,range)
// @NA
// @ERROR
// @PI
// @ABS
// @INT
// @EXP
// @SQRT
// @LN
// @LOG10
// @SIN
// @ASIN
// @COS
// @ACOS
// @TAN
// @ATAN
abstract class Function extends AbstractValue implements Iterable<Value>
{
protected final Sheet parent;
@ -39,6 +18,8 @@ abstract class Function extends AbstractValue implements Iterable<Value>
return new Error (parent, cell, "@ERROR");
}
if (text.charAt (1) == 'A')
{
if (text.startsWith ("@ABS("))
return new Abs (parent, cell, text);
@ -56,7 +37,9 @@ abstract class Function extends AbstractValue implements Iterable<Value>
if (text.startsWith ("@AVERAGE("))
return new Average (parent, cell, text);
}
else if (text.charAt (1) == 'C')
{
if (text.startsWith ("@COUNT("))
return new Count (parent, cell, text);
@ -65,13 +48,17 @@ abstract class Function extends AbstractValue implements Iterable<Value>
if (text.startsWith ("@COS("))
return new Cos (parent, cell, text);
}
else if (text.charAt (1) == 'E')
{
if (text.startsWith ("@ERROR"))
return new Error (parent, cell, text);
if (text.startsWith ("@EXP"))
return new Exp (parent, cell, text);
}
else if (text.charAt (1) == 'I')
{
if (text.startsWith ("@IF("))
return new If (parent, cell, text);
@ -83,7 +70,9 @@ abstract class Function extends AbstractValue implements Iterable<Value>
if (text.startsWith ("@ISNA("))
return new IsNa (parent, cell, text);
}
else if (text.charAt (1) == 'L')
{
if (text.startsWith ("@LOG10("))
return new Log10 (parent, cell, text);
@ -92,25 +81,35 @@ abstract class Function extends AbstractValue implements Iterable<Value>
if (text.startsWith ("@LN("))
return new Ln (parent, cell, text);
}
else if (text.charAt (1) == 'M')
{
if (text.startsWith ("@MIN("))
return new Min (parent, cell, text);
if (text.startsWith ("@MAX("))
return new Max (parent, cell, text);
}
else if (text.charAt (1) == 'N')
{
if (text.equals ("@NA"))
return new Na (parent, cell, text);
if (text.startsWith ("@NPV("))
return new Npv (parent, cell, text);
}
else if (text.charAt (1) == 'O')
{
if (text.startsWith ("@OR("))
return new Or (parent, cell, text);
}
else if (text.charAt (1) == 'P')
{
if (text.startsWith ("@PI"))
return new Pi (parent, cell, text);
}
else if (text.charAt (1) == 'S')
{
if (text.startsWith ("@SIN("))
return new Sin (parent, cell, text);
@ -119,9 +118,12 @@ abstract class Function extends AbstractValue implements Iterable<Value>
if (text.startsWith ("@SQRT("))
return new Sqrt (parent, cell, text);
}
else if (text.charAt (1) == 'T')
{
if (text.startsWith ("@TAN("))
return new Tan (parent, cell, text);
}
System.out.printf ("Unknown function: [%s]%n", text);
return new Error (parent, cell, "@ERROR");