Sign in to follow this  
Followers 0
Chobyhy

Improving CPU Help

6 posts in this topic

Is it better if I have a 1 big script with all functions and everything in 1 script or if i clutter them into several different script such as series of this function in one script and gui in others and stuff then use #include?

Which way will use less CPU and faster response?

Share this post


Link to post
Share on other sites



Is it better if I have a 1 big script with all functions and everything in 1 script or if i clutter them into several different script such as series of this function in one script and gui in others and stuff then use #include?

Which way will use less CPU and faster response?

CPU and Response depends on how you code it, using an #include is no different than just having the code in the script itself as it is written to your script at compile time anyway.

I find separating my bigger projects into multiple includes makes for cleaner coding and easier to find and fix bugs.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Yes this is a big project. So I'm planning to stretch it out a little but how will like While 1 - WEnd in each script compile over each other. How does the compiler compile 3 scripts into one. Do they just add each part at the end of each script such as

Script 1

+

Script 2

+

Script 3

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Forget about the compiler while you learn this part of scripting. The principles are the same even if you run the script from within SciTE. Think about it this way, you can open a new au3 file using SciTE and paste in your code from Script 1 and below that, your code from Script 2 and so on. If you have a While/WEnd loop in your code for Script 1 that never exits, then your new "big script" will never run the code that came from Script 2. If all of your 3 or so scripts are wrapped in simple While/WEnd loops. Then the way to combine them is to place them all within one While/WEnd loop:

While 1 ;only/main/infinite loop

Script 1

+

Script 2

+

Script 3

WEnd

...and remove any other infinite While/WEnd loops from the code in between the main While/WEnd loop.

Clear as mud?

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Dont use use #Include at the top?

Share this post


Link to post
Share on other sites

Dont use use #Include at the top?

Using include (at the top or otherwise) is functionally the same as a copy and paste of the code that you "included". The order of the "includes" is the order of the code in the main/big script.

For example:

#include --> script 1

#include --> script 2

#include --> script 3

is the same as:

script 1

script 2

script 3

If you have some infinite loops in scripts 1, 2 and 3... so, just doing an include will not work for you - unless you remove the infinite loops from the scripts to be included in your main script.

I'm not sure how else to explain it because I'm unclear as to what part of this you are not understanding. I would just skip all "includes" and have all applicable code within one file (then use code folding for readability)... but that it just me. A professional would probably prefer much smaller/testable chucks of code.

...hope that helps...


[size="1"][font="Arial"].[u].[/u][/font][/size]

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