Code: Select all
;execute_this
;execute_end
;exit_this
;exit_end
ex_this() solves this problem (in most cases) by letting you add to the auto-execute section (or exit subroutine) from anywhere in your script
it also solves the problem of getting "label not found" errors when you remove a file but forgot to remove the goSub or timer that was in the auto-execute section
another benefit of using this method is that sharing code with others becomes easier since everything is self contained in one file.
if the person youre sharing a script with is also using ex_this() then all they have to do is include it into their own script and reload to get things up and running.
if theyre not, then the execute/exit tags can act sort of like instructions about which parts need to be copied to auto-execute section of their script
lastly, since the execute/exit tags are just comments, they dont have any effect if someone decides to run the script it on its own
drawbacks
ex_this() copies the code between the execute/exit tags and then stores it in \AppData\Local\Temp\ex_this\
this means means that msgBox errors will show that location and not the source file, as will certain variables such as a_lineFile.
in certain situations you might be able to work around these problems by using the "goto error" timer or by using the following function to convert a_lineFile to the actual source file
Code: Select all
source_file := ex_source(a_lineFile)
also, i have around 100 or so separate files included into my main script and i use about 15 execute/exit_this tags so i cant say for sure how well this will work if it has to scan 1000s of files every time you reload
other methods?
i had this idea a while back and just went and made it without thinking too much about different ways of doing it, so i would be curious to know if there are any alternative or better ways that ive missed
more words n stuff in the gist readme
gist code