Jump to content

#include and #include


SImplify
 Share

Recommended Posts

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

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

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

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

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

Link to comment
Share on other sites

  • Administrators

;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
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Administrators

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.
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...