I would like to make a plugin system for one of my scripts. I want it to work something like this -> check a given dir for plugin files (*.plg for example) -> include functions in these files to my script.
And I had a few ideas, but none of them worked.
Idea nr1
Combine all *.plg files into one and include this one in a typical way (#include). But it failes, because (from what I understand) includes are done out-of-script order during compilation.
Idea nr2
Call a function include
If $CmdLineRaw <> "-ALLOK" Then
FileInstall(*PATH TO THIS SOURCE*, @TEMPDIR&"\temp.au3")
$filehandle = FileFindFirstFile ( @ScriptDir&"\*.plg" )
While $filehandle <> -1
$file = FileFindNextFile($filehandle)
If @error Then ExitLoop
FileWrite(@TEMPDIR&"\temp.au3", @CRLF&FileRead($file)&@CRLF)
Wend
Run(@AutoItEXE&' /AutoIt3ExecuteScript "'&@TEMPDIR&'\temp.au3" -ALLOK')
Exit
EndIf
;;;;;Your normal main script code here.