I mean something like get_included_files();
in php or Error().stack;
in javascript or $BASH_SOURCE
array in bash ?
I've only found in macros ( https://www.autoitscript.com/autoit3/docs/macros.htm ) @ScriptFullPath
and @ScriptName
.
I mean something like get_included_files();
in php or Error().stack;
in javascript or $BASH_SOURCE
array in bash ?
I've only found in macros ( https://www.autoitscript.com/autoit3/docs/macros.htm ) @ScriptFullPath
and @ScriptName
.
You can implement the functionality by using a global variable. Say
$includeDepth
.$includeDepth
should be incremented by 1 before any#include
and decremented by 1 after it. If$includeDepth
is0
, then the code is not running as part of an#include
. For example:You need to be very consistent in this usage, though. However, as long as library
#include
s don't include your own scripts (or scripts where this checking is done), there is no need to modify them. From this point of view, it's also not necessary to increment/decrement$includeDepth
while including library#include
s. However, it doesn't hurt and it reinforces the practice.Yes there is a way. Check if @ScriptName matches the name of the current script. If it doesn't your script has been included in something else. I use this method to run a unit test if an included script is run as a stand alone script. I add the following code to the end of included_script.au3...
When included in a "main.au3" file, the @ScriptName will be set to "main.au3" and it will not run test()