Changeset 202
- Timestamp:
- 08/08/08 11:03:47 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Simple.java
r190 r202 325 325 } 326 326 327 private static void RunFrame(Frame frame, Text current, boolean acceptKeyboardInput,328 boolean step, int pause, Color color) {327 private static void RunFrame(Frame frame, Text current, 328 boolean acceptKeyboardInput, boolean step, int pause, Color color) { 329 329 try { 330 330 DisplayIO.addToBack(current.getParent()); … … 354 354 } 355 355 356 public static void RunFrame(Frame frame, Text current, boolean acceptKeyboardInput) { 356 public static void RunFrame(Frame frame, Text current, 357 boolean acceptKeyboardInput) { 357 358 RunFrame(frame, current, acceptKeyboardInput, false, 0, null); 358 359 } … … 368 369 * @param pause 369 370 */ 370 public static void DebugFrame(Frame frame, Text current, float pause, Color color) { 371 public static void DebugFrame(Frame frame, Text current, float pause, 372 Color color) { 371 373 if (isProgramRunning()) { 372 374 stop(); … … 794 796 // Add the variables in the system 795 797 context.getPrimitives().addToParser(myParser); 796 Node equation = myParser.parseExpression(toCalculate); 797 // TODO get the answer 798 if (equation == null) { 798 try { 799 Node equation = myParser.parse(toCalculate); 800 String value = myParser.evaluate(equation, false); 801 // Add a new variable if its an assignment statement 802 String newVar = SReal.prefix + myParser.getNewVariable(); 803 if (newVar.length() > 0) { 804 try { 805 context.getPrimitives().setValue(newVar, 806 new SString(value)); 807 } catch (IncorrectTypeException e) { 808 result = false; 809 error = e.getMessage(); 810 } 811 } 812 if (tokens.length > 2) { 813 context.getPrimitives().setValue(tokens[2], 814 new SString(value)); 815 } 816 // TODO get the answer 817 } catch (Throwable e) { 799 818 result = false; 800 error = myParser.getErrorInfo().replace("\n", ""); 801 } else { 802 double value = myParser.getValue(); 803 if (myParser.hasError()) { 804 result = false; 819 if (myParser.getErrorInfo() == null) { 820 error = e.getMessage(); 821 } else { 805 822 error = myParser.getErrorInfo().replace("\n", ""); 806 } else {807 // Add a new variable if its an assignment statement808 String newVar = myParser.getNewVariable();809 if (newVar.length() > 0) {810 try {811 context.getPrimitives().setValue(newVar,812 new SReal(value));813 } catch (IncorrectTypeException e) {814 result = false;815 error = e.getMessage();816 }817 }818 if (tokens.length > 2) {819 context.getPrimitives().setValue(tokens[2],820 new SReal(value));821 }822 823 } 823 824 } -
trunk/src/org/expeditee/gui/DisplayIO.java
r199 r202 65 65 * The title to display in the Title bar. 66 66 */ 67 public static final String TITLE = "Exp0 7Aug2008A";67 public static final String TITLE = "Exp08Aug2008A"; 68 68 69 69 private DisplayIO() { -
trunk/src/org/expeditee/math/ExpediteeJEP.java
r196 r202 50 50 } 51 51 52 public String evaluate(Node node) throws ParseException{ 52 public String evaluate(Node node) throws ParseException { 53 return evaluate(node, true); 54 } 55 56 public String evaluate(Node node, boolean prependVarName) 57 throws ParseException { 53 58 Object rawResult = super.evaluate(node); 54 59 if (rawResult instanceof Double) { 55 Double result = (Double) rawResult;60 Double result = (Double) rawResult; 56 61 if (result.isNaN()) { 57 62 return null; … … 64 69 String varName = observer.toString(); 65 70 if (varName.length() > 0) 66 return varName + ": " + nf.format(result); 71 return (prependVarName ? (varName + ": ") : "") 72 + nf.format(result); 67 73 68 74 return nf.format(result); … … 88 94 frame, t.getEnclosedShape()); 89 95 String variableName = t.getText().toLowerCase(); 90 96 91 97 addVectorVariable(enclosed, variableName); 92 98 } … … 102 108 for (Item i : items) { 103 109 if (i instanceof Text && !i.isLineEnd()) { 104 Double value = AttributeUtils.getDoubleValue(i 105 .getText()); 110 Double value = AttributeUtils.getDoubleValue(i.getText()); 106 111 if (value != null) { 107 112 vector.add(value); … … 110 115 } 111 116 if (vector.size() > 0) 112 addVariable(variableName, MVector 113 .getInstance(vector.toArray())); 117 addVariable(variableName, MVector.getInstance(vector.toArray())); 114 118 } 115 119 -
trunk/src/org/expeditee/simple/Primitives.java
r190 r202 272 272 try { 273 273 Double value = var.doubleValue(); 274 myParser.addVariable(var.getName() , value);274 myParser.addVariable(var.getName().substring(SReal.prefix.length()), value); 275 275 } catch (Exception e) { 276 276 }
Note:
See TracChangeset
for help on using the changeset viewer.