Jump to content
Sign in to follow this  
Lantz

Run Function located in main script from included sub script

Recommended Posts

Lantz

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?

Share this post


Link to post
Share on other sites
Jos

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Lantz

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?

Share this post


Link to post
Share on other sites
kylomas

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×