Jump to content

correct organization of #include keyword thru several files


Recommended Posts

  • Developers

Nah, not when all use array udfs as stated.

Honestly, just add it to each for file to allow you to tun the files individually as include is only include one time for the first #include statement as array.au3 has an #include-once.

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

I agree with Jos, for maximal flexibility use the include in all three scripts, but I will try to be a bit more verbose.

I assume you drawing must be interpreted as follows.
func1 is used in main but is declared in a1
func2 is used in a1 but is declared in a2

For editing/checking/running Main it is only required to include array in Main.
Drawback, a1 and a2 are incomplete because these can not be syntax checked/run without the include array.
For editing/checking/running a2 you have to include array in a2.

So only a1 remains to be decided. It gets the array include already with the include for a2.
But let's assume you later decide to change a2 so it does no longer need the include array!
You edit/check/run a2 and yes it is done!
You check/run Main, no errors so you assume everything is fine!
Later you want to change something to a1, edit/check/run.
Oh no, now a1 will suddenly fail on syntaxcheck, complaining about unknown array functions.
So, yes also for a1, just use the include array.

The array.au3 file itself has the include-once directive, so including this include several times is no problem.
In your a1 and a2 the use of include-once is not really necessary, but it won't cause problems either.
 

Link to comment
Share on other sites

Another way to think about it is that the #include'd script will simply be inputted into the run/compiled script. Think of it as instead of #including, you're just copy/pasting the entire file into the main script at that point that it's included. So in the original example, it would look like (indenting just to make it easier to separate):

; Main.au3
[Main.au3 data]
    [Array.au3 data]
    [end Array.au3]
    [a1.au3 data]
        [a2.au3 data]
            func2()
            ...
        [end a2.au3]

        func1()
        ...
            func2()
        ....
    [end a1.au3]

    func1()
[end Main.au3]
; End

Since everything that's included has #include-once, it won't be included again after the initial time.

We ought not to misbehave, but we should look as though we could.

Link to comment
Share on other sites

and what about the functions?

func1():  exist in Main.au3 and in  a1.au3 (declare?,  call?)
func2():  exist in a1.au3 and in  a2.au3 (declare?,  call?)

maybe the func name will have to be changed :)

Edited by ioa747
correction

I know that I know nothing

Link to comment
Share on other sites

  • 2 weeks later...

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