Jump to content

Recommended Posts

Posted

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

Posted

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

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
Posted

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

Posted

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

Posted

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

  • Administrators
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


 

  • Developers
Posted

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

  • Administrators
Posted

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.


 

Posted

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

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
×
×
  • Create New...