diff -r 7cadc624cc74 -r 996515c4b394 TextViewer.py --- a/TextViewer.py Wed Sep 05 12:38:41 2012 +0200 +++ b/TextViewer.py Wed Sep 05 12:39:50 2012 +0200 @@ -29,7 +29,7 @@ import re from graphics.GraphicCommons import ERROR_HIGHLIGHT, SEARCH_RESULT_HIGHLIGHT, REFRESH_HIGHLIGHT_PERIOD -from plcopen.structures import ST_BLOCK_START_KEYWORDS, ST_BLOCK_END_KEYWORDS, IEC_BLOCK_START_KEYWORDS, IEC_BLOCK_END_KEYWORDS +from plcopen.structures import ST_BLOCK_START_KEYWORDS, ST_BLOCK_END_KEYWORDS, IEC_BLOCK_START_KEYWORDS, IEC_BLOCK_END_KEYWORDS, LOCATIONDATATYPES from controls import EditorPanel #------------------------------------------------------------------------------- @@ -324,11 +324,31 @@ elif var_name.upper() in [name.upper() for name in self.Controler.GetEditedElementVariables(self.TagName, self.Debug)]: message = _("\"%s\" element for this pou already exists!")%var_name else: + location = values[0] + if not location.startswith("%"): + dialog = wx.SingleChoiceDialog(self.ParentWindow, + _("Select a variable class:"), _("Variable class"), + ["Input", "Output", "Memory"], + wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL) + if dialog.ShowModal() == wx.ID_OK: + selected = dialog.GetSelection() + else: + selected = None + dialog.Destroy() + if selected is None: + event.SetDragText("") + return + if selected == 0: + location = "%I" + location + elif selected == 1: + location = "%Q" + location + else: + location = "%M" + location if values[2] is not None: var_type = values[2] else: - var_type = LOCATIONDATATYPES.get(values[0][2], ["BOOL"])[0] - self.Controler.AddEditedElementPouVar(self.TagName, var_type, var_name, values[0], values[4]) + var_type = LOCATIONDATATYPES.get(location[2], ["BOOL"])[0] + self.Controler.AddEditedElementPouVar(self.TagName, var_type, var_name, location, values[4]) self.RefreshVariablePanel() self.RefreshVariableTree() event.SetDragText(var_name)