Lantz Posted March 13, 2013 Posted March 13, 2013 Hi! lets say i have my main script main.au3, that among other things contains this: #include<subscript.au3> func logg($TextToLog) FileWrite("log.txt", $TextToLog) EndFunc Is there anyway that a function located in subscript.au3 can run the logg function from main.au3?
Developers Jos Posted March 13, 2013 Developers Posted March 13, 2013 It isn't a best practice, but when you think how the #include works you can give the answer yourself. All #include files are placed at the locations of the #include statements before the execution of the script starts! Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Lantz Posted March 13, 2013 Author Posted March 13, 2013 Including the main script in the sub script? The idea had crossed my mind but i was hoping there was a neater way to do it. What is your general tip for situations like this, where you need multiple subscripts to do the same functions. Simply putting the needed function in all subscripts? Making one subscript that has all shared functions and including it in all subscripts? Something more clever?
kylomas Posted March 13, 2013 Posted March 13, 2013 Lantz, This looks like a logging function that may be called repeatedly and/or from different places. This is the function that should be in an include file and then called from wherever you like. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
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