Sign in to follow this  
Followers 0
Manus-Magnus

Best way to organize my 2000 lines "script" ??

9 posts in this topic

HI,

i'm building a script, very big one since it have more than 2000 lines, i have functions using 90% of space, any idea of i should separate in multiple parts/files this code ?

tx you for suggestions

MM :whistle:

Share this post


Link to post
Share on other sites



Put your functions in a logical order and use semi-colons to create comments?

For example:

;Return the value of XYZ
Function Func1()
Your function code
EndFunc
;
;Call application 123
Function Func2()
Your function code
EndFunc

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You can put common funtions you use often in your own file, and pull them into the main script.

; my script
$x=1
Func1($x)
...
...
Exit

#include "myfunctions.au3"

; myfunctions.au3
;Return the value of XYZ
Function Func1()
Your function code
EndFunc
;
;Call application 123
Function Func2()
Your function code
EndFunc

Warning, #include files will be all compiled together at the time you compile it into an exe. So if you plan on including a function file, or any other, it will be pulled in and compiled. If you change the function file, you will need to recompile in order to get any changes.

This is unlike reading an external file, as say an INI file. for values, since #include files can have script executable code, it is compiled at the time you create the Exe.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

have you tried optimizing your code into 500 lines or less??

do you see a pattern of repeating commands?

like....if you were use MsgBox while blockinput(1)...

you could create and use a separate function called mymsgbox($message)

instead of constantly repeating

blockinput(0)

msgbox(....

blockinput(1)

you'd have only one line instead of three.....


[quote]I was busy waiting all night for the Columbus Day Bunny to come down my chimney and light fireworks in my pumpkin.There's so much wrong with that.Oh, I'm sorry, i forgot you were Jewish.[/quote]

Share this post


Link to post
Share on other sites

have you tried optimizing your code into 500 lines or less??

do you see a pattern of repeating commands?

like....if you were use MsgBox while blockinput(1)...

you could create and use a separate function called mymsgbox($message)

instead of constantly repeating

blockinput(0)

msgbox(....

blockinput(1)

you'd have only one line instead of three.....

yes man, im just a phsyco maniac about "factorise" (contatenate/optimize... im french sorry B) ) my code, i create alot generic functions with 1 to 8 entry parameters and arrays returns...for multiple usage

but now i have near 3000 lines.

but with #include i select functions by "themes" ( i have 10 files of them actually) and use editor with "folder view" btw i can access in 2 sec fo the lib i need and make changes.

i didnt founded a bug yet , this autoit3 is a fantastic tool tx you Jon ! :whistle: and i will enjoy the final release !!

ps: if you can optimise the pixelsearch integrated function that should be just great too :angry:

Share this post


Link to post
Share on other sites

be sure to use a LOT of comments too :whistle: it will make things a lot easier to edit later....... trust me.


~~ Safeguarding The Land ~~

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