Ahk-Best-Practices
Ahk-Best-Practices copied to clipboard
Library Import Style
I think libraries and codes(like. functions) from other files should be included separately under a declarative comment like:
/*
**********************************
libraries used
***********************************
*/
#include libcrypt.ahk
#include tf.ahk
either at the top of the file or at bottom as per the need.
I put them at the top as per the C/C++ convention.
I would have put them at the top but as AHK is a scripting language and runs from top to bottom, putting a lib on top scares me that lib code may get executed at startup. You see AHK has no main()
method like those. But this is so silly :stuck_out_tongue_winking_eye:
Well that is true, libraries are to (or should) be written in a way that it does not disrupt the script no matter where they are included. This point could be added to this "style" guide.
I don't know. Maybe it's too advanced level for this guide. You know, writing a library, that kind of thing. Also there is no package manager for ahk. You just copy the code and paste it to a new file, or download something from GitHub. The lib code is not inaccessible like Python/Go/Java. Also library authors are sensible enough to not include auto-execute stuff in their scripts. If they have, you can always remove it when you have downloaded it locally.
I never include i always use stlib
Still trying to get ASPDM going, right now it's functional, it's just that the website isn't exactly complete and some small things here and there... :p