dinodod Posted August 26, 2005 Share Posted August 26, 2005 I was wondering how I could best seperate my GUI from the functional code. I see the Include command & Call command but is there any way to call a function from an external file? The Include command will execute the .au3 file and terminate. What i am trying to do is hold all my functions in a external file and simply call the function from my main file. Is there such a way to do that? If not, is there a way to load the external file and hold it in memory (Include terminates the file when it's done) Thanks! Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007 Link to comment Share on other sites More sharing options...
Valuater Posted August 26, 2005 Share Posted August 26, 2005 I was wondering how I could best seperate my GUI from the functional code. I see the Include command & Call command but is there any way to call a function from an external file?The Include command will execute the .au3 file and terminate. What i am trying to do is hold all my functions in a external file and simply call the function from my main file.Is there such a way to do that? If not, is there a way to load the external file and hold it in memory (Include terminates the file when it's done)Thanks!<{POST_SNAPBACK}>I think this is what your looking forfist save this file as "messageBox.au3" and place it in the "include" folder of AutoitFunc MESSAGEBOX() MsgBox(0,"TEST", "This is an include functuion test... OK") EndFuncthen here is the gui... note it has the include message box at the top#include <GUIConstants.au3> #include <MessageBox.au3> GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode",2) $btn_ok = GUICtrlCreateButton ("OK", 10, 30, 50) $btn_cancel = GUICtrlCreateButton ( "Cancel", 0, -1) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $btn_cancel Then ExitLoop If $msg = $btn_ok Then call("MessageBox") EndIf Wendi tested this and it works..... hope it helps8) Link to comment Share on other sites More sharing options...
dinodod Posted August 26, 2005 Author Share Posted August 26, 2005 Interesting.. From my reading in the help file, I thought it would load the file & terminate it. Thanks for clearing that up. Here is the Help File example: ;;; TIME.AU3 ;;; MsgBox(0,"", "The time is " & @HOUR & ":" & @MIN & ":" & @SEC) ;;; SCRIPT.AU3 ;;; #include "TIME.AU3" MsgBox(0,"", "Example") #include "TIME.AU3" Exit ; Running script.au3 will output three message boxes: ; one with the time, one with 'Example', and another with the time. Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007 Link to comment Share on other sites More sharing options...
Hooch Posted August 26, 2005 Share Posted August 26, 2005 I seperate all my code into seperate files and stick them in a /bin directory under my main script directory and just include them at the top of my parent script file like this: #Include <gui_Constants.au3> #Include <bin\functions.au3> #Include <bin\gui_Main.au3> Link to comment Share on other sites More sharing options...
Sokko Posted August 26, 2005 Share Posted August 26, 2005 I suppose that from a technical standpoint, calling a file with #include does indeed load, run, and terminate it. The point that the example fails to mention is that any functions or variables defined in the included script will remain in memory for the rest of the main script. This is an easy way to load large sets of user-created functions, or to assign names to a large number of constants for greater ease of use (like in GUIConstants.au3). Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 26, 2005 Moderators Share Posted August 26, 2005 I believe Snake wrote a UDF that trims the #include variables to just what that script needs. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
quaizywabbit Posted August 27, 2005 Share Posted August 27, 2005 I suppose that from a technical standpoint, calling a file with #include does indeed load, run, and terminate it. The point that the example fails to mention is that any functions or variables defined in the included script will remain in memory for the rest of the main script. This is an easy way to load large sets of user-created functions, or to assign names to a large number of constants for greater ease of use (like in GUIConstants.au3).<{POST_SNAPBACK}>if you have compiled an exe that uses #include(s) , decompile it and you'll see that the included script is literally merged into the main script starting at the line # the #include was on [u]Do more with pre-existing apps![/u]ANYGUIv2.8 Link to comment Share on other sites More sharing options...
MHz Posted August 27, 2005 Share Posted August 27, 2005 I seperate all my code into seperate files and stick them in a /bin directory under my main script directory and just include them at the top of my parent script file like this:#Include <gui_Constants.au3> #Include <bin\functions.au3> #Include <bin\gui_Main.au3><{POST_SNAPBACK}>Whenever i look into a bin directory, I normally find binary files. Seems to be a custom for bin folders. 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