Fix bug in extraction and computation of array initial value
authorlaurent
Wed, 14 Sep 2011 23:06:05 +0200
changeset 557 0f591ac019f3
parent 556 69214983dd03
child 558 01e2c3d58a27
Fix bug in extraction and computation of array initial value
plcopen/plcopen.py
--- a/plcopen/plcopen.py	Wed Sep 14 23:05:04 2011 +0200
+++ b/plcopen/plcopen.py	Wed Sep 14 23:06:05 2011 +0200
@@ -2355,6 +2355,7 @@
 cls = PLCOpenClasses.get("value", None)
 if cls:
     def setvalue(self, value):
+        value = value.strip()
         if value.startswith("[") and value.endswith("]"):
             arrayValue = PLCOpenClasses["value_arrayValue"]()
             self.content = {"name" : "arrayValue", "value" : arrayValue}
@@ -2408,8 +2409,11 @@
         values = []
         for element in self.value:
             repetition = element.getrepetitionValue()
-            if repetition is not None and repetition > 1:
-                values.append("%s(%s)"%(repetition, element.getvalue()))
+            if repetition is not None and int(repetition) > 1:
+                value = element.getvalue()
+                if value is None:
+                    value = ""
+                values.append("%s(%s)"%(repetition, value))
             else:
                 values.append(element.getvalue())
         return "[%s]"%", ".join(values)