pedrit0

keep '#include' au3 file editable after compiling main exe

18 posts in this topic

#1 ·  Posted (edited)

Hi all.

I have created an external au3 (a library of functions and vars) that is #included in a main script that i must compile.

I wish that the content of the library is not merged with the main script when compiling.

My goal is to keep the ability to modify the library even after the main exe is compiled and that these changes are effective when executing the exe.

I guess this is not possible using the standard #include method.

Is there a way to do that ?

thx a lot :-)

Edited by pedrit0

Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

Share this post


Link to post
Share on other sites



I am having trouble understanding why you would need to do that?  If you want to read dynamic data into your application you can use a file.  You can also shellexecute au3 source files against the autoit exe.  Perhaps you can explain what you are trying to specifically accomplish for a more precise answer?


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Hi Jfish

I have 2 files:

- mainscript.au3

- FunctionLibrary.au3 that contains the functions to be used by mainscript

I want to compile mainscript.au3 but not FunctionLibrary.au3 because i want to be able to modify it later without having to recompile the mainscript.

I know this behavior is not possible with the #include method that would merge the library to the mainscript during compilation. Which means that the external library would become useless.

So I am looking for another method.


Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

Share this post


Link to post
Share on other sites

Yes, that much is clear.   But why do you need to modify the functions post-compiling of the exe without including them in the compiled code?  What specifically are you trying to accomplish?  There may be a better way.   


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

29 minutes ago, pedrit0 said:

because i want to be able to modify it later without having to recompile the mainscript

My only goal. For an IT project. The exe would run 'in production' on a server and its function library can be edited/updated without having to modify the main exe.

Can you develop about ' shellexecute au3 source files' ? Sounds interesting but when I google it it seems not to fit exactly to what I need.

Edited by pedrit0

Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

Share this post


Link to post
Share on other sites

What are the type of functions in your .au3 file?

Share this post


Link to post
Share on other sites

To be more specific, this library strictly contains var statements and functions. No processing.


Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

Share this post


Link to post
Share on other sites

External functions that do not stick to the script own structure. These functions can be altered/modified without threatening the main script process.

The vars are global vars that could be used by several scripts later.


Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

Share this post


Link to post
Share on other sites

What I mean is that I cannot pass trough using ini or xml files as a workaround. The goal is really to store some functions in the library.


Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

Share this post


Link to post
Share on other sites

#10 ·  Posted

How would the main script know about the new functions so as to execute them ... ini files would work for the vars, but you are saying you can't use those.  Why?  What is the difference between that and using an au3 file that contains the same info?


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

#11 ·  Posted

Oh I get your misunderstanding... sorry. I have made up this system:

- I have an ini file listing some steps of processings. Step# = FunctionName()

- I have the main script parsing the ini file and executing the iniread as a function call in a loop, whatever the function is and whatever its name. So no need to know the function for the main script.

- the function to be executed is stored in the functionlibrary.au3

- several persons need to update / add functions in the library without recompiling anything.


Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

Share this post


Link to post
Share on other sites

#12 ·  Posted

sounds like executing raw au3 files against the au3 exe from your main script as fed by the ini would work ... 

I created a program called "scriptrunner" that did basically that.  You could record scripts, edit them, and sequence them to be run from the main application.  There may be other ways that are better but I will defer to others for those ... 


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

#13 ·  Posted

yep but my issue remains : how to keep the library out ???


Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

Share this post


Link to post
Share on other sites

#15 ·  Posted

:-) that would be heaven if I could. These functions are to be called from the main exe.


Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I have just tried but the global vars declared in the library are not detected by the main script... but i think this a good clue and I try out all I can with that tomorrow. Tired. Going to bed. thx a lot for the time you have spent on the topic :-)

Edited by pedrit0

Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

to be noted : when using that you must disable Au3Check before compilation... it won't like unexplicitely declared vars.

Edited by pedrit0

Pedrit0, calme et tranquille, la tete dans les nuages et la b*** dans le champagne.

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

  • Similar Content

    • TrashBoat
      By TrashBoat
      How do i add a path to a file in Include.
      I want my script to get the udf in the same folder as the script/exe:
      Include "@ScriptDir/udf.au3" can this be done?
    • ur
      By ur
      I have recorded a gui installation and modified the au3 file as per my requirement.
      But the problem is, whenever I try to compile the au3 file, I am getting a special character on top of the file.

      Can you suggest how to resolve this as it is appearing everytime during compilation.
      And also I am trying to include a au3 file which is separate folder so I am adding the <..\Library.au3> line.
      It is able to pick that but in that file "Library.au3" there is a file install line.
      FileInstall(".\SendMail.ps1", @ScriptDir & "\SendMail.ps1") Library.au3 is being used by many other codes in the previous folder..
      But the current file is looking for the ps1 file in current folder.
      So is there any option to tell the compiler to pick the dependent files relative to Library.au3 instead of the current code.
    • xiantez
      By xiantez
      Hey AutoIT Community,
      Just wanted to know if there is a way I can #include all *.au3 files in my script without having to #include each individual .au3 file. For instance, currently I have a laundry list of #includes like this:
      #include <IE.au3>
      #include <Inet.au3>
      #include <AutoItConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <GDIPlus.au3>
      #include <GuiMenu.au3> 
      [ECT...ECT...]
      Would there be a way I could include all of the files above or all  .au3 file in a one liner? That way I do not have to burn up a bunch of lines of code for just my includes.... Your help is greatly appreciated...
    • Miliardsto
      By Miliardsto
      Is there possibility to do it like this?
      Cause as I see compiler doesn't see If statement in case of #include functions.
      It includes these two files all time.
      If $var == True Then #include 'func/funcsByTabs/main_Moda.au3' Else #include 'func/funcsByTabs/main_Others.au3' EndIf  
    • AmarokStudios
      By AmarokStudios
      Good afternoon AutoIt community!,
      I was on Stackoverflow the other day and came across this question: How To Include Files From A Directory. This got me thinking... There has to be a way to do it... After a bunch of research, I wasn't able to find anything. So, I created this UDF to dynamically include every file from the directory. Of course, there are some bugs that I'd like to fix eventually, but for the most part, it works. Simply call the main function (Shown below) right after the rest of the includes before any of your actual code, and the UDF will include all of the au3 files in the specified directory. Without further ado, here is the _includeDir UDF and how to use it!
       
      _includeDir.au3
       
      Download this code (_includeDir.au3 attached as well) and place it into the directory with your current script. Next, include it in your main file. For now, I'm going to be using one called Example.au3.
       
      #Include "_includeDir.au3" Now, include whatever else you're going to be including in this script, then call the _includeDir function. NOTE: THIS MUST BE CALLED AT THE TOP OF THE SCRIPT, BEFORE ANY CODE IS WRITTEN! THE FUNCTION FORCES THE SCRIPT TO RESTART SO PUTTING IT LATER IN THE SCRIPT WILL RE-RUN THE CODE!
       
      Example.au3
      #Include "_includeDir.au3" #Include <File.au3> ; Not needed. Just here as an example of a normal script. #Include <Array.au3> ; Not needed. Just here as example of normal script. _includeDir("Directory to Include") MsgBox(0,"Example","This is just an example!") See how the function is called near the top? This is the proper use of the UDF. If you had a folder called "Directory to Include" and had a bunch of .au3 files inside of it, the function would include them all into the Example.au3 script.
      If you run the Example.au3 file now, it will most likely tell you "The directory Things to Include does not exist!". Make sure you enter the name of the directory you're trying to include. Just as a side note, when including files, you should put all of the code in the INCLUDED files inside of functions so they aren't automatically run when included. Variables can be outside of the functions so they are automatically set. Remember, if you have a variable in one included file with the same name of variable in another included file, it will be overwritten with whichever include file was included last.
       
      Anyways, if you have pointed the directory to include parameter to a folder that exists and run the Example.au3, it will generate a folder called IncludeDirUDF. It will also write a new line inside of Example.au3. It will write the line 
      on line one. Of course, you don't always want it to be written to line one, right? Maybe you want this bit of code to be written on line 3 in order to keep your code organize. Is there a way to do this? Absolutely! Simply add the line number as a second parameter to the function. For example, we want to have this bit of code written on line 3, we would set up our Example.au3 file to look like this.
      #Include "_includeDir.au3" #Include <File.au3> ; Not needed. Just here as an example of a normal script. #Include <Array.au3> ; Not needed. Just here as example of normal script. _includeDir("Directory to Include", 3) MsgBox(0,"Example","This is just an example!") See how we added the 3 to the end of _includeDir? This will tell the function to write the #Include "IncludeDirUDF\loadIncludes.au3" on line 3 of Example.au3. Note, the line HAS TO EXIST in order to be written to it. For example, if your Example.au3 code only has 6 lines, and you specify to be written on line 7, it WILL NOT WORK.
       
      The code is designed to include and restart in order to process the included files. For some reason, if you want to JUST generate the included file and NOT restart, you can add one more parameter to the code. If you don't want the code to restart, simply set your code up to look like this:
      #Include "_includeDir.au3" #Include <File.au3> ; Not needed. Just here as an example of a normal script. #Include <Array.au3> ; Not needed. Just here as example of normal script. _includeDir("Directory to Include", 3, False) MsgBox(0,"Example","This is just an example!") Note, if you set this last parameter to false, it will simply generate the included file and write to line 3 of Example.au3 (As specified before) and exit before the code reaches the MsgBox() and it will not be displayed.
       
      The last important thing to note: In order to re-include a different set of files, you must delete the #Include "IncludeDirUDF\loadIncludes.au3" from your main script (In this case, Example.au3) and delete the generated file, IncludeDirUDF. Now you can simply rerun Example.au3 and it will include any the dir with any changes you made to it. Only .au3 files should be in the directory you're trying to include as it will not process the other files and will generate an error.
       
      I hope this UDF helps somebody out! Comment any questions/concerns you may have and I will try to address them as soon as possible!
       
      Thanks,
      Timothy
      CEO - Amarok Studios
      _includeDir.au3