mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-11 04:29:45 +00:00
reworking functions
This commit is contained in:
parent
14c6e4e3cc
commit
687453d11c
@ -72,12 +72,13 @@ DFE3 PTRGET
|
||||
|
||||
E053 find a variable
|
||||
E10C convert FP to INT
|
||||
E2F2 convert ACC to FP
|
||||
E2F2 GIVAYF - convert (A,Y) to FP
|
||||
E301 SNGFLT
|
||||
E3E7 FPSTR2
|
||||
E6F8 GETBYTE
|
||||
E74C COMBYTE
|
||||
E752 GETADR - get from FAC to LINNUM
|
||||
E7A0 FADDH
|
||||
E7A7 FSUB
|
||||
E7BE FADD
|
||||
E8D5 OVERFLOW
|
||||
@ -86,12 +87,21 @@ E941 FLOG
|
||||
E97F FMULT
|
||||
E9E3 CONUPK
|
||||
EA39 MUL10
|
||||
EA55 DIV10
|
||||
EA66 FDIV
|
||||
EAE1 DIVERR
|
||||
EAF9 MOVEFM - move (A,Y) to FAC
|
||||
EB2B MOVEMF
|
||||
EAF9 MOVEFM (Y,A) -> FAC
|
||||
EB1E MOV2F FAC -> TEMP2
|
||||
EB21 MOV1F FAC -> TEMP1
|
||||
EB23 MOVML FAC -> (O,X)
|
||||
EB2B MOVMF FAC -> (Y,A)
|
||||
EB53 MOVFA ARG -> FAC
|
||||
EB63 MOVAF (Y,A) -> ARG
|
||||
EB82 SIGN
|
||||
EB90 SGN
|
||||
EB93 FLOAT
|
||||
EBA0 FLOAT1 - integer to FAC ($9D-$A2)
|
||||
EBAF FABS
|
||||
EBB2 FCOMP
|
||||
EBF2 QINT
|
||||
EC23 FINT
|
||||
@ -99,11 +109,11 @@ EC4A FIN
|
||||
ED24 LINPRNT - print a decimal number
|
||||
ED2E PRNTFAC
|
||||
ED34 FOUT - FAC to FBUFFR ($100-$110)
|
||||
EE8D SQR
|
||||
EE8D FSQR
|
||||
EE97 FPWRT
|
||||
EED0 NEGOP
|
||||
EF09 FEXP
|
||||
EFAE RND
|
||||
EFAE FRND
|
||||
EFEA FCOS
|
||||
EFF1 FSIN
|
||||
|
||||
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Count extends Function
|
||||
{
|
||||
Range range;
|
||||
private final Range range;
|
||||
private boolean hasChecked;
|
||||
private double count = 0;
|
||||
|
||||
public Count (Sheet parent, String text)
|
||||
{
|
||||
@ -10,18 +12,36 @@ public class Count extends Function
|
||||
range = getRange (text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue ()
|
||||
{
|
||||
if (!hasChecked)
|
||||
calculate ();
|
||||
return hasValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue ()
|
||||
{
|
||||
double result = 0;
|
||||
if (!hasChecked)
|
||||
calculate ();
|
||||
return hasValue ? count : 0;
|
||||
}
|
||||
|
||||
private void calculate ()
|
||||
{
|
||||
hasChecked = true;
|
||||
hasValue = false;
|
||||
|
||||
for (Address address : range)
|
||||
{
|
||||
Cell cell = parent.getCell (address);
|
||||
if (cell != null && cell.hasValue () && cell.getValue () != 0.0)
|
||||
result += 1;
|
||||
if (cell != null && cell.hasValue ())
|
||||
{
|
||||
hasValue = true;
|
||||
if (cell.getValue () != 0.0)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -36,7 +36,6 @@ public class Expression implements Value
|
||||
|
||||
public Expression (Sheet parent, String input)
|
||||
{
|
||||
// System.out.printf ("Exp [%s]%n", line);
|
||||
String line = checkBrackets (input);
|
||||
|
||||
int ptr = 0;
|
||||
@ -113,21 +112,6 @@ public class Expression implements Value
|
||||
|
||||
assert values.size () > 0;
|
||||
hasValue = true;
|
||||
|
||||
if (false)
|
||||
{
|
||||
ptr = 0;
|
||||
for (Value val : values)
|
||||
{
|
||||
System.out.println (signs.get (ptr));
|
||||
if (val == null)
|
||||
System.out.println ("null");
|
||||
else
|
||||
System.out.println (val.getValue ());
|
||||
if (ptr < operators.size ())
|
||||
System.out.println (operators.get (ptr++));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,6 +21,7 @@ public class Lookup extends Function
|
||||
}
|
||||
|
||||
// need a mechanism to return NA and ERROR
|
||||
@Override
|
||||
public boolean hasValue ()
|
||||
{
|
||||
return hasValue;
|
||||
@ -34,7 +35,6 @@ public class Lookup extends Function
|
||||
Address target = null;
|
||||
for (Address address : range)
|
||||
{
|
||||
// System.out.printf ("%s : %s%n", source, address);
|
||||
Cell cell = parent.getCell (address);
|
||||
if (cell != null && cell.getValue () > sourceValue)
|
||||
break;
|
||||
|
@ -31,6 +31,8 @@ public class Max extends Function
|
||||
private void calculate ()
|
||||
{
|
||||
hasChecked = true;
|
||||
hasValue = false;
|
||||
|
||||
for (Address address : range)
|
||||
{
|
||||
Cell cell = parent.getCell (address);
|
||||
|
@ -31,6 +31,8 @@ public class Min extends Function
|
||||
private void calculate ()
|
||||
{
|
||||
hasChecked = true;
|
||||
hasValue = false;
|
||||
|
||||
for (Address address : range)
|
||||
{
|
||||
Cell cell = parent.getCell (address);
|
||||
|
@ -18,27 +18,27 @@ class Number implements Value
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue ()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return String.format ("Number: %f", value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue ()
|
||||
{
|
||||
return hasValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue ()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getError ()
|
||||
{
|
||||
return hasValue ? "" : "@NA";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return String.format ("Number: %f", value);
|
||||
}
|
||||
}
|
@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.visicalc;
|
||||
|
||||
public class Sum extends Function
|
||||
{
|
||||
Range range;
|
||||
private final Range range;
|
||||
private boolean hasChecked;
|
||||
private double sum = 0;
|
||||
|
||||
public Sum (Sheet parent, String text)
|
||||
{
|
||||
@ -10,18 +12,35 @@ public class Sum extends Function
|
||||
range = getRange (text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue ()
|
||||
{
|
||||
if (!hasChecked)
|
||||
calculate ();
|
||||
return hasValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue ()
|
||||
{
|
||||
double result = 0;
|
||||
if (!hasChecked)
|
||||
calculate ();
|
||||
return hasValue ? sum : 0;
|
||||
}
|
||||
|
||||
public void calculate ()
|
||||
{
|
||||
hasChecked = true;
|
||||
hasValue = false;
|
||||
|
||||
for (Address address : range)
|
||||
{
|
||||
Cell cell = parent.getCell (address);
|
||||
if (cell != null && cell.hasValue ())
|
||||
result += cell.getValue ();
|
||||
{
|
||||
hasValue = true;
|
||||
sum += cell.getValue ();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user