[Idea for V2.1:] Wish "Script2" could import modules from "CompiledScript.exe" by default.

Discuss the future of the AutoHotkey language
User avatar
V2User
Posts: 228
Joined: 30 Apr 2021, 04:04

[Idea for V2.1:] Wish "Script2" could import modules from "CompiledScript.exe" by default.

Post by V2User » 15 Oct 2024, 05:30

[Code1:]

Code: Select all

Run('CompiledScript.exe /script /ErrorStdOut Script2.ahk')
Wish "Script2" could import module name from CompiledScript.exe by default rather than from real lib folders, if the module name to import has been already imported in CompiledScript.exe.

This would be extremely useful, if "script2" is launched with no lib folders, such as from stdIn i.e. script2's name is *, while CompiledScript.exe is the main script and is compiled.

lexikos
Posts: 9811
Joined: 30 Sep 2013, 04:07
Contact:

Re: [Idea for V2.1:] Wish "Script2" could import modules from "CompiledScript.exe" by default.

Post by lexikos » 13 Dec 2024, 17:54

The main script (#1) of CompiledScript.exe is neither executed nor even read when you use /script. It makes no sense to check for Import directives while ignoring everything else.

If you want to prefix some code (such as an Import directive) to every script loaded by CompiledScript.exe, use the #2 resource. #Module could also be used, but then the main script will not be in the default module.

It was my intention that embedded modules be supported eventually, but I gave it only passing thought (and passing mention in V2.1 support in Ahk2Exe).

User avatar
V2User
Posts: 228
Joined: 30 Apr 2021, 04:04

Re: [Idea for V2.1:] Wish "Script2" could import modules from "CompiledScript.exe" by default.

Post by V2User » 14 Dec 2024, 12:00

I suddenly feel perhaps you are right. The module name imported from memory i.e. `CompiledScript.exe` can not be the same with the module name imported from real files. Otherwise, any update to the "modules" where the `CompiledScript.exe` exports, will have the possibility to unexpectedly cover the existing directives such as `Import X`, while `X` is the newly added "module" in `Script2.ahk` at the same time.

Post Reply

Return to “AutoHotkey Development”