SpreadsheetCells with Circular References support iterations.
[simantics/platform.git] / bundles / org.simantics.spreadsheet.graph / src / org / simantics / spreadsheet / graph / SpreadsheetCell.java
index 7d04e9b6e21c607bb80b30bce98ed10ac8a5489c..b7536f83aa906eed9457356d387ff44336408997 100644 (file)
@@ -101,22 +101,26 @@ public class SpreadsheetCell implements SpreadsheetElement, SheetNode {
                                AstValue value = ((SpreadsheetFormula)content).value;\r
                                if(this.inProgress == true) this.iterations++;\r
                                \r
-                               if(env.iterationEnabled == false){\r
+                               if(!env.getBook().isIterationEnabled()){\r
                                        if(this.inProgress == false){\r
                                                this.inProgress = true;\r
                                                f.result = value.accept(visitor);\r
                                        }\r
                                        else f.result = FormulaError2.CIRCULAR_REF.getString();\r
                                }\r
-                               else if(iterations<env.iterationLimit){\r
+                               else if(this.iterations<env.iterationLimit){\r
                                        this.inProgress = true;\r
                                        f.result = value.accept(visitor);\r
                                }\r
-                               else f.result = 0.0;\r
+                               else {\r
+                                       if(f.result==null)\r
+                                               f.result = 0.0;\r
+                               }\r
                                \r
                                env.getBook().registerReferences(makeReferenceKey(), visitor.getReferences());\r
                        }\r
                        this.inProgress = false;\r
+                       this.iterations = 0;\r
                        return (T)f.result;\r
                } else if (content instanceof SpreadsheetSCLConstant) {\r
                    SpreadsheetSCLConstant sclConstant = (SpreadsheetSCLConstant) content;\r