--- a/controls/VariablePanel.py Mon Jun 25 23:10:49 2012 +0200
+++ b/controls/VariablePanel.py Thu Jun 28 12:00:45 2012 +0200
@@ -247,44 +247,51 @@
values = None
if values is not None:
if col != wx.NOT_FOUND and row != wx.NOT_FOUND:
- if self.ParentWindow.Table.GetColLabelValue(col, False) != "Location":
- return
- if not self.ParentWindow.Table.GetValueByName(row, "Edit"):
- message = _("Can't give a location to a function block instance")
- elif self.ParentWindow.Table.GetValueByName(row, "Class") not in ["Local", "Global"]:
- message = _("Can only give a location to local or global variables")
- elif values is not None and values[1] == "location":
- location = values[0]
- variable_type = self.ParentWindow.Table.GetValueByName(row, "Type")
- base_type = self.ParentWindow.Controler.GetBaseType(variable_type)
- if location.startswith("%"):
- if base_type != values[2]:
- message = _("Incompatible data types between \"%s\" and \"%s\"")%(values[2], variable_type)
- else:
- self.ParentWindow.Table.SetValue(row, col, location)
- self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
- self.ParentWindow.SaveValues()
+ colname = self.ParentWindow.Table.GetColLabelValue(col, False)
+ if colname == "Location" and values[1] == "location":
+ if not self.ParentWindow.Table.GetValueByName(row, "Edit"):
+ message = _("Can't give a location to a function block instance")
+ elif self.ParentWindow.Table.GetValueByName(row, "Class") not in ["Local", "Global"]:
+ message = _("Can only give a location to local or global variables")
else:
- if location[0].isdigit() and base_type != "BOOL":
- message = _("Incompatible size of data between \"%s\" and \"BOOL\"")%location
- elif location[0] not in LOCATIONDATATYPES:
- message = _("Unrecognized data size \"%s\"")%location[0]
- elif base_type not in LOCATIONDATATYPES[location[0]]:
- message = _("Incompatible size of data between \"%s\" and \"%s\"")%(location, variable_type)
- else:
- dialog = wx.SingleChoiceDialog(self.ParentWindow, _("Select a variable class:"), _("Variable class"), ["Input", "Output", "Memory"], wx.OK|wx.CANCEL)
- if dialog.ShowModal() == wx.ID_OK:
- selected = dialog.GetSelection()
- if selected == 0:
- location = "%I" + location
- elif selected == 1:
- location = "%Q" + location
- else:
- location = "%M" + location
+ location = values[0]
+ variable_type = self.ParentWindow.Table.GetValueByName(row, "Type")
+ base_type = self.ParentWindow.Controler.GetBaseType(variable_type)
+ if location.startswith("%"):
+ if base_type != values[2]:
+ message = _("Incompatible data types between \"%s\" and \"%s\"")%(values[2], variable_type)
+ else:
self.ParentWindow.Table.SetValue(row, col, location)
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
self.ParentWindow.SaveValues()
- dialog.Destroy()
+ else:
+ if location[0].isdigit() and base_type != "BOOL":
+ message = _("Incompatible size of data between \"%s\" and \"BOOL\"")%location
+ elif location[0] not in LOCATIONDATATYPES:
+ message = _("Unrecognized data size \"%s\"")%location[0]
+ elif base_type not in LOCATIONDATATYPES[location[0]]:
+ message = _("Incompatible size of data between \"%s\" and \"%s\"")%(location, variable_type)
+ else:
+ dialog = wx.SingleChoiceDialog(self.ParentWindow, _("Select a variable class:"), _("Variable class"), ["Input", "Output", "Memory"], wx.OK|wx.CANCEL)
+ if dialog.ShowModal() == wx.ID_OK:
+ selected = dialog.GetSelection()
+ if selected == 0:
+ location = "%I" + location
+ elif selected == 1:
+ location = "%Q" + location
+ else:
+ location = "%M" + location
+ self.ParentWindow.Table.SetValue(row, col, location)
+ self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
+ self.ParentWindow.SaveValues()
+ dialog.Destroy()
+ elif colname == "Initial Value" and values[1] == "Constant":
+ if not self.ParentWindow.Table.GetValueByName(row, "Edit"):
+ message = _("Can't set an initial value to a function block instance")
+ else:
+ self.ParentWindow.Table.SetValue(row, col, values[0])
+ self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
+ self.ParentWindow.SaveValues()
elif (element_type not in ["config", "resource"] and values[1] == "Global" and self.ParentWindow.Filter in ["All", "Interface", "External"] or
element_type in ["config", "resource"] and values[1] == "location"):
if values[1] == "location":