256 message = _("Can only give a location to local or global variables") |
256 message = _("Can only give a location to local or global variables") |
257 else: |
257 else: |
258 location = values[0] |
258 location = values[0] |
259 variable_type = self.ParentWindow.Table.GetValueByName(row, "Type") |
259 variable_type = self.ParentWindow.Table.GetValueByName(row, "Type") |
260 base_type = self.ParentWindow.Controler.GetBaseType(variable_type) |
260 base_type = self.ParentWindow.Controler.GetBaseType(variable_type) |
261 if location.startswith("%"): |
261 |
262 if base_type != values[2]: |
262 if values[2] is not None: |
|
263 base_location_type = self.ParentWindow.Controler.GetBaseType(values[2]) |
|
264 if values[2] != variable_type and base_type != base_location_type: |
263 message = _("Incompatible data types between \"%s\" and \"%s\"")%(values[2], variable_type) |
265 message = _("Incompatible data types between \"%s\" and \"%s\"")%(values[2], variable_type) |
264 else: |
266 |
265 self.ParentWindow.Table.SetValue(row, col, location) |
267 if message is None: |
266 self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
268 if not location.startswith("%"): |
267 self.ParentWindow.SaveValues() |
269 if location[0].isdigit() and base_type != "BOOL": |
268 else: |
270 message = _("Incompatible size of data between \"%s\" and \"BOOL\"")%location |
269 if location[0].isdigit() and base_type != "BOOL": |
271 elif location[0] not in LOCATIONDATATYPES: |
270 message = _("Incompatible size of data between \"%s\" and \"BOOL\"")%location |
272 message = _("Unrecognized data size \"%s\"")%location[0] |
271 elif location[0] not in LOCATIONDATATYPES: |
273 elif base_type not in LOCATIONDATATYPES[location[0]]: |
272 message = _("Unrecognized data size \"%s\"")%location[0] |
274 message = _("Incompatible size of data between \"%s\" and \"%s\"")%(location, variable_type) |
273 elif base_type not in LOCATIONDATATYPES[location[0]]: |
|
274 message = _("Incompatible size of data between \"%s\" and \"%s\"")%(location, variable_type) |
|
275 else: |
|
276 dialog = wx.SingleChoiceDialog(self.ParentWindow.ParentWindow.ParentWindow, |
|
277 _("Select a variable class:"), _("Variable class"), |
|
278 ["Input", "Output", "Memory"], |
|
279 wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL) |
|
280 if dialog.ShowModal() == wx.ID_OK: |
|
281 selected = dialog.GetSelection() |
|
282 else: |
275 else: |
283 selected = None |
276 dialog = wx.SingleChoiceDialog(self.ParentWindow.ParentWindow.ParentWindow, |
284 dialog.Destroy() |
277 _("Select a variable class:"), _("Variable class"), |
285 if selected is None: |
278 ["Input", "Output", "Memory"], |
286 return |
279 wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL) |
287 if selected == 0: |
280 if dialog.ShowModal() == wx.ID_OK: |
288 location = "%I" + location |
281 selected = dialog.GetSelection() |
289 elif selected == 1: |
282 else: |
290 location = "%Q" + location |
283 selected = None |
291 else: |
284 dialog.Destroy() |
292 location = "%M" + location |
285 if selected is None: |
|
286 return |
|
287 if selected == 0: |
|
288 location = "%I" + location |
|
289 elif selected == 1: |
|
290 location = "%Q" + location |
|
291 else: |
|
292 location = "%M" + location |
|
293 |
|
294 if message is None: |
293 self.ParentWindow.Table.SetValue(row, col, location) |
295 self.ParentWindow.Table.SetValue(row, col, location) |
294 self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
296 self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
295 self.ParentWindow.SaveValues() |
297 self.ParentWindow.SaveValues() |
296 elif colname == "Initial Value" and values[1] == "Constant": |
298 elif colname == "Initial Value" and values[1] == "Constant": |
297 if not self.ParentWindow.Table.GetValueByName(row, "Edit"): |
299 if not self.ParentWindow.Table.GetValueByName(row, "Edit"): |