Sign in to follow this  
Followers 0
coolooc

include same file twice

8 posts in this topic

Hi,

I'm using functions from one file in two different files, so i include this file in both of them.

I run the functions in those files from another file, so i include both of them in that file.

Example:Files- file_general_func, file1, file2, file_main.

file1: #include "file_general_func"

file2: #include "file_general_func"

file_main: #include "file1", #include "file2"

After build this script i gets "WARNING: already included file:"

Removing the #include "file_general_func" from both files and include it only in "file_main" worked for a while, but after some changes I got error or "undefined function"

How can i solve it?

Thanks,

Shany

Share this post


Link to post
Share on other sites



You could use directive "#include-once" in your script.

So if you include the same file a second time it is ignored.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I got "syntax error" for writing:

#include-once "general_func.au3"

Share this post


Link to post
Share on other sites

Oh in the file... sorry.

Thanks!

Share this post


Link to post
Share on other sites

In your script as first "statement":

#include-once
#include <file1.au3>
#include <file2.au3>

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I maybe wrong here but im not sure as i dont include many files like this but im taking it that most your coding is happening in file_main so if you included the rest in that one wouldnt it pass the information to the rest of the files?

File_main.au3 <=== file your coding in
#include <file1.au3>
#include <file2.au3>
#include <file_gen_funcs.au3>

;All other code here

Then if you needed to test something in file1 or 2 you could just add #include <gen_funcs.au3> run/test the code and then comment it out/delete it from the top of the script and run it all though File_main again? Like i said maybe im wrong but thts how i would do it if it works.

Share this post


Link to post
Share on other sites

I mentioned it in the first message.

I tried to include all the files in the main file, and it worked first, but for some reason after some additions and changes in the code i got error "undefined function". include all the files in the main file may not be the reason, but changing it to #include-once helped.

Thank you!

Share this post


Link to post
Share on other sites

Glad your problem could be solved :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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  
Followers 0