Gregor_S Posted May 26, 2023 Share Posted May 26, 2023 Good afternoon, would be very thankful if you correct me in terms of using #include keyword thru several files (see diagram). Thank you. Link to comment Share on other sites More sharing options...
Gregor_S Posted May 26, 2023 Author Share Posted May 26, 2023 here, all three au.3 files are using functions from <Array.au3> Link to comment Share on other sites More sharing options...
ioa747 Posted May 26, 2023 Share Posted May 26, 2023 I think #include <Array.au3> from main.au3 - could be removed. as long as he gets it from a2.au3 file I know that I know nothing Link to comment Share on other sites More sharing options...
Developers Jos Posted May 26, 2023 Developers Share Posted May 26, 2023 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 More sharing options...
OJBakker Posted May 26, 2023 Share Posted May 26, 2023 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 More sharing options...
mistersquirrle Posted May 26, 2023 Share Posted May 26, 2023 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 More sharing options...
ioa747 Posted May 27, 2023 Share Posted May 27, 2023 (edited) 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 May 27, 2023 by ioa747 correction I know that I know nothing Link to comment Share on other sites More sharing options...
Gregor_S Posted June 5, 2023 Author Share Posted June 5, 2023 Good evening, thanks everyone for the explanations. mistersquirrle - gave a clear way to think. So, practically its enough to include <Array.au3> once. Made a quick example. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now