Lexikos wrote:
trismarck wrote:
What is the definition of a library file?
A file from a
function library, included automatically because of a function-call, or explicitly with #include <>.
Thanks, now I get it. I had doubts if by 'library file' you mean only a file included with #include <> as #include <> has some special meaning.
Quote:
Quote:
why would someone want to provide an #include ext_lib directive inside lib1.ahk library file ...
One would use #include in a library file for the same reasons one would use #include anywhere else.
Quote:
... if at the same time he'd know that in order to use any of the function inside the lib1.ahk library, he'd have to include that lib1.ahk library file in some other file (like main.ahk).
I don't understand what you think the problem is. If lib1 depends on lib2, either the user must #include
both libs in their script (even if they don't explicitly use lib2) or lib1 must #include lib2. If lib1 is split into multiple files, the user should not need to #include each individual file.
I've tested #includes further in ahkB and it appears that approach 2) from my first post will always fail. Here is an example:
File structure
Code:
project\
|-main.ahk ; #inlcude %A_ScriptDir% ; |if main.ahk compiled|
; #include lib\chair.ahk
|-lib\ ; lib\ or any other folder really
|-chair.ahk ; #include %A_ScriptDir%
; #include ext\cabinet.ahk ; |this fails| ; if chair.ahk compiled, this works
|-ext\
|-cabinet.ahk
main.ahk
Code:
#include %A_ScriptDir%
#include lib\chair.ahk
chair_beat()
return
chair.ahk
Code:
#include %A_ScriptDir% ; fails if chair.ahk library included into main.ahk
; (main.ahk directory above chair.ahk directory)
#include ext\cabinet.ahk
chair_beat() {
MsgBox, % "To beat the dust out of the chair, I need a carpet beater."
cabinet_carpetBeater()
MsgBox, % "Done. Dust removed from chair."
}
cabinet.ahk
Code:
cabinet_carpetBeater() {
MsgBox, % "Carpet beater working."
}
A workaround would be a solution 1) from my first post:
main.ahk
Code:
#include %A_ScriptDir%
#include lib\ext\cabinet.ahk ; required by chair.ahk
#include lib\chair.ahk
chair_beat()
return
chair.ahk
Code:
#include *i ext\cabinet.ahk ; workaround so main.ahk would work
chair_beat() {
MsgBox, % "To beat the dust out of the chair, I need a carpet beater."
cabinet_carpetBeater()
MsgBox, % "Done. Dust removed from chair."
}
In ahkL everything is much simpler because of #include <>.