SirJohann Posted January 6, 2014 Share Posted January 6, 2014 Hi guys. Just a little question. I am not new in AutoIt, or programming in general, so you can answer me the hardest way that you can. Do you think is a good idea encapsulate a GUI(Main and the only GUI in the script) in a func? Not a func that have a loop and still until the user ends, just a func to create the GUI in vars already declared as global(the script is on event mode, so the variables can be local too without any problem, because I don't need them later in a GUIGetMsg loop) and then return. It's a good idea or a bad idea? Or the worst idea in all the time and space? Global Const iX = 300, $iY = 600 Global Const $sTitle = 'Patheditor', $sAddButtonText = 'Add', $sDeleteButtonText = 'Delete' Global $hMainGui Global $iAddButton, $iDeleteButton, $iPathList _MainGuiStartup() _RefreshList() _MainLoop() Func _MainGuiStartup() $hMainGui = GUICreate($sTitle, $iX, $iY) $iAddButton = GUICtrlCreateButton($sAddButtonText, 2, $iY - (($iY / 24) - 2), ($iX / 2) - 1, $iY / 24) $iDeleteButton = GUICtrlCreateButton($sDeleteButtonText, ($iX / 2) + 1, $iY - (($iY / 24) - 2), ($iX / 2) - 1, $iY / 24) $iPathList = GUICtrlCreateList('', 2, 2, $iX - 2, $iY - (($iY / 24) - 5)) Local $aMainGuiAccelTable[2][2] = [['^a', $iAddButton], ['^d', $iDeleteButton]+ GUISetState(@SW_SHOW, $hMainGui) GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit') GUICtrlSetOnEvent($iAddButton, '_Add') GUICtrlSetOnEvent($iDeleteButton, '_Delete') GUISetAccelerators($aMainGuiAccelTable, $hMainGui) Endfunc Codes codes codes. Link to comment Share on other sites More sharing options...
gruntydatsun Posted January 6, 2014 Share Posted January 6, 2014 Was the time and space comment along with hair disturbingly similar to Tom Baker a deliberate Dr Who reference? re the gui encapsulation in a function, I wouldn't bother putting it in a function as the code won't be reused. Still, if it improves readability for you then it doesn't do any harm. Link to comment Share on other sites More sharing options...
SirJohann Posted January 6, 2014 Author Share Posted January 6, 2014 Whovians in the forum, awesome Well, I was thinking that maybe I could reuse it later, but I think I'm having a little problem of over-engineering and exaggerating for just a simple %path% editor. Codes codes codes. Link to comment Share on other sites More sharing options...
mikell Posted January 6, 2014 Share Posted January 6, 2014 All the examples in the helpfile concerning guis are encapsulated in a func Example() I don't think it would have been done like this if such a thing was potentially toxic Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now