allow @IF(cond,@NA,

This commit is contained in:
Denis Molony 2017-03-17 22:03:56 +11:00
parent 4b1bc7bd64
commit 4f62914924
7 changed files with 46 additions and 10 deletions

View File

@ -54,6 +54,7 @@ public abstract class AbstractFile implements DataSource
if (buffer.length <= 999999)
return HexFormatter.format (buffer, 0, buffer.length);
System.out.println ("**** truncating hex dump");
return HexFormatter.format (buffer, 0, 999999);
}
@ -66,7 +67,7 @@ public abstract class AbstractFile implements DataSource
@Override
public JComponent getComponent ()
{
System.out.println ("In AbstractFile.getComponent()");
// System.out.println ("In AbstractFile.getComponent()");
JPanel panel = new JPanel ();
return panel;
}

View File

@ -148,7 +148,7 @@ public abstract class HiResImage extends AbstractFile
break;
case ProdosConstants.FILE_TYPE_PNT: // 0xC0
if (auxType == 0)
if (auxType == 0) // see Asimov disks/images/gs/programming/fta_code/GIFT5.SDK
auxText = "Paintworks Packed SHR Image";
else if (auxType == 1)
auxText = "Packed Super Hi-Res Image";

View File

@ -118,6 +118,7 @@ public class TextFile extends AbstractFile
int size = buffer.length;
int lastVal = 0;
boolean newFormat = true;
boolean showAllOffsets = false;
if (newFormat)
{
@ -133,10 +134,10 @@ public class TextFile extends AbstractFile
while (ptr < size)
{
int val = buffer[ptr++] & 0x7F; // strip hi-order bit
int val = buffer[ptr++] & 0x7F; // strip hi-order bit
if (val == 0)
++nulls;
else if (val == 0x0D) // carriage return
else if (val == 0x0D) // carriage return
text.append ("\n");
else
{
@ -149,7 +150,10 @@ public class TextFile extends AbstractFile
nulls = 0;
}
else if (lastVal == 0x0D && newFormat)
text.append (" ");
if (showAllOffsets)
text.append (String.format ("%6d ", ptr - 1));
else
text.append (" ");
text.append ((char) val);
}

View File

@ -182,6 +182,8 @@ class Cell extends AbstractValue implements Comparable<Cell>
return " " + Format.justify (value.getText (), colWidth - 1, fmtChar);
}
if (colWidth == 1)
return ".";
return " " + Format.format (value, fmtChar, colWidth - 1);
default:

View File

@ -29,12 +29,14 @@ class Condition extends AbstractValue implements Iterable<Value>
if (pos > 0)
{
conditionText = text.substring (0, pos);
valueText = text.substring (pos + comp.length ());
conditionExpression = new Expression (parent, cell, conditionText);
valueExpression = new Expression (parent, cell, valueText);
values.add (conditionExpression);
values.add (valueExpression);
comparator = comp;
valueText = text.substring (pos + comp.length ());
valueExpression = new Expression (parent, cell, valueText);
values.add (valueExpression);
break;
}
}
@ -44,8 +46,14 @@ class Condition extends AbstractValue implements Iterable<Value>
if (text.startsWith ("@"))
{
conditionText = text;
valueText = "1";
conditionExpression = new Expression (parent, cell, text);
values.add (conditionExpression);
comparator = "=";
valueText = "1";
valueExpression = new Expression (parent, cell, valueText);
values.add (valueExpression);
}
else
System.out.println ("No comparator and not a function");

View File

@ -310,6 +310,16 @@ class Expression extends AbstractValue implements Iterable<Value>
return text.substring (0, ptr + 1); // include closing parenthesis
}
static String getFunctionName (String text, int offset)
{
int pos1 = text.indexOf ('(', offset);
int pos2 = text.indexOf (',', offset);
if (pos1 > offset && pos1 < pos2)
return text.substring (offset, pos1);
return text.substring (offset, pos2);
}
private String getNumberText (String text)
{
int ptr = 0;

View File

@ -26,7 +26,18 @@ class If extends Function
if (functionText.charAt (pos1 + 1) == '@')
{
textTrue = Expression.getBalancedText (functionText.substring (pos1 + 1));
String functionName = Expression.getFunctionName (functionText, pos1 + 1);
int nameLength = functionName.length ();
if (functionText.charAt (pos1 + nameLength + 1) == ',') // no brackets or parameters
{
// System.out.printf ("no parameters [%s]%n", functionName);
textTrue = functionName;
}
else
{
textTrue = Expression.getBalancedText (functionText.substring (pos1 + 1));
// System.out.printf ("parameters [%s]%n", textTrue);
}
// System.out.printf ("True : %s%n", textTrue);
expTrue = new Expression (parent, cell, textTrue);
pos2 = functionText.indexOf (',', pos1 + textTrue.length () + 1);