From: lempinen Date: Wed, 30 May 2012 10:04:10 +0000 (+0000) Subject: Fixed the problem with multiple sheets. A return statement was called after the first... X-Git-Tag: simantics-1.6~1^2~2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=e6c3d4f78be6086b2800afb23167c1bfc331c639;p=simantics%2Fsysdyn.git Fixed the problem with multiple sheets. A return statement was called after the first sheet had been formatted => Other sheets did not know that values are read from them. (refs #3477) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@25071 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Sheet.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Sheet.java index 85331ac2..71a3b756 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Sheet.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Sheet.java @@ -66,7 +66,7 @@ public class Sheet extends org.simantics.sysdyn.representation.Variable { final StringBuilder clazz = new StringBuilder(); final HashSet possibleRanges = new HashSet(); - clazz.append(" class " + name + "_class\n "); + clazz.append(" class " + name + "_class\n"); // Write all doubles that have been used in expressions int counter = 0; @@ -83,7 +83,7 @@ public class Sheet extends org.simantics.sysdyn.representation.Variable { if(value instanceof Double) { Double d = (Double)value; - clazz.append("constant Real " + key + " = " + d + "; "); + clazz.append(" constant Real " + key + " = " + d + "; "); counter++; if(counter > 10) { counter = 0; @@ -116,7 +116,7 @@ public class Sheet extends org.simantics.sysdyn.representation.Variable { if(array[0].length > 1) { // Has two dimensions - clazz.append("constant Real[" + array.length + ", " + array[0].length + "] "); + clazz.append(" constant Real[" + array.length + ", " + array[0].length + "] "); clazz.append(possibleRange.replace(":", "_") + " = {"); for(int i = 0; i < array.length; i++) { clazz.append("{"); @@ -132,7 +132,7 @@ public class Sheet extends org.simantics.sysdyn.representation.Variable { clazz.append("};\n"); } else { // Has one dimension - clazz.append("constant Real[" + array.length + "] "); + clazz.append(" constant Real[" + array.length + "] "); clazz.append(possibleRange.replace(":", "_") + " = {"); for(int i = 0; i < array.length; i++) { clazz.append(array[i][0]); @@ -151,7 +151,7 @@ public class Sheet extends org.simantics.sysdyn.representation.Variable { } - clazz.append("\n end " + name + "_class;\n"); + clazz.append(" end " + name + "_class;\n"); clazz.append(" " + name + "_class " + name + ";\n"); return clazz.toString(); } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/SheetFormatUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/SheetFormatUtils.java index 0eb9f750..19b14ce8 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/SheetFormatUtils.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/SheetFormatUtils.java @@ -73,7 +73,7 @@ public class SheetFormatUtils { String tmp = ""; int start = 0, end = 0, call = 0; String cellOrRange = null; - while((call = expression.indexOf(key, end)) >= 0) { + while((call = expression.indexOf(key + "(", end)) >= 0) { start = expression.indexOf("(", call); tmp += expression.substring(end, start); @@ -101,7 +101,7 @@ public class SheetFormatUtils { tmp += "." + cellOrRange; } tmp += expression.substring(end, expression.length()); - return tmp; + expression = tmp; } }