Jump to content

include same file twice


coolooc
 Share

Recommended Posts

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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
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!

Link to comment
Share on other sites

Glad your problem could be solved :D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...