Sign in to follow this  
Followers 0
SImplify

#include and #include

12 posts in this topic

Hi there,

Quick question.

I have three files.

main.au3

main_functions.au3

functions.au3

In the top of main.au3 I have

#include "main_functions.au3"

#include "functions.au3"

Now I will need to call one_function (=functions.au3) also in file main_functions.au3 but I have not succeed to do that. I have #include-once statement in functions.au3 and main_functions.au3 and then I try to add #include "functions.au3" in main_function.au3 I got error message -> ERROR: one_function() already defined.

Can you help me?

Cheers

Simplify

Share this post


Link to post
Share on other sites



I am having trouble following the scenario, could you post your code or an example that does the same things?

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

;main.au3
#include "functions.au3"
#include "main_functions.au3"

.....
logi()
;works fine

------------------

;functions.au3
#include-once
func logi()
;write some log
endfunc

------------------

;main_functions

;How can I call function logi() here?
;like below
func some()
   logi()
endfunc

By including functions.au3 in main_functions file I got error message: ERROR: logi() already defined.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Are the two logi functions identical?

Could you copy and paste the exact error syntax into the forum?

*** Matt @ MPCS

Edited by Matt @ MPCS

Share this post


Link to post
Share on other sites

Are the two logi functions identical?

Could you copy and paste the exact error syntax into the forum?

*** Matt @ MPCS

<{POST_SNAPBACK}>

There are only one logi function (in functions.au3) and I would like to call that function both in main.au3 and main_functions.au3. If I put #include "functions.au3" in top of functions_main.au3 file the exact error message are: ERROR: function log() already defined.

Cheers

Share this post


Link to post
Share on other sites

Why do you need #include-once in functions.au3? That is the problem.

What I am unsure of is if you include functions.au3 in main_functions.au3, and then include main_functions.au3 in main.au3, will main.au3 have the ability to call functions from functions.au3?

Graphically:

If main.au3 > includes > main_functions.au3 > which includes > functions.au3

can main.au3 > access functions in-----------------------------------------^ ?

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

Why do you need #include-once in functions.au3? That is the problem.

What I am unsure of is if you include functions.au3 in main_functions.au3, and then include main_functions.au3 in main.au3, will main.au3 have the ability to call functions from functions.au3?

Graphically:

If main.au3 > includes > main_functions.au3 > which includes > functions.au3

can main.au3 > access functions in-----------------------------------------^ ?

*** Matt @ MPCS

<{POST_SNAPBACK}>

BIG Thxs! Now it works!

What I thought was, that you can include whatever whereever if you had that #include-once statements in included files.

Cheers

Simplify

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

;main.au3
#include "functions.au3"
#include "main_functions.au3"

.....
logi()
;works fine

------------------

;functions.au3
#include-once
func logi()
;write some log
endfunc

------------------

;main_functions

;How can I call function logi() here?
;like below
func some()
   logi()
endfunc

By including functions.au3 in main_functions file I got error message: ERROR: logi() already defined.

If i add '#include "functions.au3" ' to main_functions.au3 it still works OK for me. Are you sure you've not got another definition of logi() somewhere. Edited by Jon

Share this post


Link to post
Share on other sites

If i add '#include "functions.au3" ' to main_functions.au3 it still works OK for me.  Are you sure you've not got another definition of logi() somewhere.

<{POST_SNAPBACK}>

try this to see it fail with:

....main_functions.au3 (5) : ==> Duplicate function name.: func some()

;main.au3
#include-once
#include "main_functions.au3"
#include "functions.au3"
logi()

;functions.au3
#include-once
#include "main_functions.au3"
func logi()
;write some log
endfunc
;main_functions
;How can I call function logi() here?
;like below

func some()
   logi()
endfunc

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

try this to see it fail with:

....main_functions.au3 (5) : ==> Duplicate function name.: func some()

;main.au3
#include-once
#include "main_functions.au3"
#include "functions.au3"
logi()

;functions.au3
#include-once
#include "main_functions.au3"
func logi()
;write some log
endfunc
;main_functions
;How can I call function logi() here?
;like below

func some()
   logi()
endfunc

Well that's fair enough, main_functions.au3 doesn't have an #include-once.

Share this post


Link to post
Share on other sites

Or you can just copy and past the funcs you need in the botton of your script.

Share this post


Link to post
Share on other sites

If i add '#include "functions.au3" ' to main_functions.au3 it still works OK for me.  Are you sure you've not got another definition of logi() somewhere.

That's how it works for me too...

Cheers

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