#Include <Foo> includes twice #4

Closed
Lexikos opened this Issue Aug 18, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@Lexikos
Contributor

Lexikos commented Aug 18, 2011

The following includes Foo.ahk twice, when compiled:

#Include <Foo>

The original Ahk2Exe writes the processed script text into a temporary file as it goes along, and passes this file to AutoHotkey.exe /iLib. Because the #Include line was stripped out before it got to AutoHotkey.exe, it didn't add the lib file to its output. I implemented #Include <Lib> support in Ahk2Exe to resolve this, though I realize now that I could have simply written the original #Include line into the temporary file and let AutoHotkey.exe do the rest.

Since your script passes the original filename to AutoHotkey.exe /iLib, both it and your script process the #Include line. This causes the file to be included twice. I think the best solution is to simply ignore any instances of #Include <Lib> and let AutoHotkey.exe handle it. You can either pass the original filename as you do now, or pass a temporary file containing the processed text.

@fincs

This comment has been minimized.

Show comment
Hide comment
@fincs

fincs Aug 18, 2011

Owner

I think your original approach is better because the library file is inserted at the same position the interpreter reads it, and there might be scripts that rely on this behaviour, especially class libraries ("Why doesn't my script work when it's compiled?"). Anyway, I think that it would be an even better idea to change AutoHotkey to not write the #Include <Lib> files to the iLib script; this would avoid the need for a temporary file and would avoid having to write said temporary file to the input script's folder (needed for resolving local library scripts), which may be read only.

Owner

fincs commented Aug 18, 2011

I think your original approach is better because the library file is inserted at the same position the interpreter reads it, and there might be scripts that rely on this behaviour, especially class libraries ("Why doesn't my script work when it's compiled?"). Anyway, I think that it would be an even better idea to change AutoHotkey to not write the #Include <Lib> files to the iLib script; this would avoid the need for a temporary file and would avoid having to write said temporary file to the input script's folder (needed for resolving local library scripts), which may be read only.

@Lexikos

This comment has been minimized.

Show comment
Hide comment
@Lexikos

Lexikos Aug 18, 2011

Contributor

Ah, yes. Now that you mention it, I think that's why I did it that way. Letting /iLib handle it would probably also cause #Include <Lib> to include the file even if there was a previous #Include Lib\Lib.ahk, although I think that case would be rare. I will make the necessary change to AutoHotkey some time in the next few days.

Contributor

Lexikos commented Aug 18, 2011

Ah, yes. Now that you mention it, I think that's why I did it that way. Letting /iLib handle it would probably also cause #Include <Lib> to include the file even if there was a previous #Include Lib\Lib.ahk, although I think that case would be rare. I will make the necessary change to AutoHotkey some time in the next few days.

@fincs fincs closed this Sep 24, 2011

fincs pushed a commit to fincs/AutoHotkey_L that referenced this issue Apr 13, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment