#Include: block auto-include

Propose new features and changes
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

#Include: block auto-include

27 Mar 2018, 18:57

[EDIT:] Lower down, I suggest modifying the list of auto-include folders (potentially to 0), rather than blanket enabling/disabling the standard 3.
#Include: block auto-include - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=46224&p=236575#p236575

- Sometimes when working with my or other people's scripts, I can have problems with getting a script to run because there is a missing function.
- Instead of getting a message saying that the function wasn't found, the script looks for the function in various libraries, some libraries are automatically included, and I get a duplicate function error.
- This could all be avoided if I could block any 'smart' behaviour, whereby the script is prevented from searching in specific folders for functions/libraries.
- (Without such blocking functionality, some script debugging has taken an absolute age.)
- Apologies if I have overlooked any existing functionality. Thanks for reading.
Last edited by jeeswg on 06 Sep 2019, 07:26, edited 2 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: #Include: block auto-include

28 Mar 2018, 02:16

I think that you should probably just manage your includes in a smart way.
Recommends AHK Studio
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: #Include: block auto-include

28 Mar 2018, 05:41

I think I agree with nnnik :lolno:
So not to create a new topic, I would like to propose two changes:
  • Allow file extension in <LibName> (e.g. <include_file.ahk/txt/ext>). Currently gives error :eh: .
  • Force the use of quotes in #Include FileOrDirName. FileOrDirName must be an expression. Why?
    • For clarity, now that everything is an expression.
    • #If use expression; why some directives should use expressions and others not?. Of course, with this in mind, it should affect all directives.
    • In the Thoughts for v2.0, it says Perhaps remove the strings "On" and "Off" since they don't work intuitively in boolean expressions, and just use true and false, if this is the case, we would only use TRUE/FALSE.
Edit* Well, maybe the second point is not a very good idea, since variables are not allowed (in other directives) and would not make sense. :facepalm: Forget it :lol:
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: #Include: block auto-include

28 Mar 2018, 08:10

Can you share some pointers nnnik? Any good tutorials that you recommend? This include stuff isn't easy for me to understand, and the docs page is not very inclusive, or else I'm just not looking right.

I don't understand why directives do not use expression syntax. Maybe it has been discussed somewhere.
try it and see
...
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: #Include: block auto-include

28 Mar 2018, 08:20

I think lexikos simply hasn't touched the general directive syntax since AHK v1 or at least not by more than it was neccessary.

#Include is actually very simple.
You write #include and refer to a file that contains code. AutoHotkey.exe then looks for that file and acts as if said code was there instead of the #include.

Code: Select all

#include script.ahk ;will act as if script.ahk is here
This is commonly used to split out pieces of code that you want to use across projects.
Normally you only write entire classes or entire functions inside such a file. Using it in a different way might lead to errors.
Also using a library name with <> and without it's extension will look for that file in specific folders.
These folders can contain libraries and you can access them from any script without problem.
Recommends AHK Studio
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: #Include: block auto-include

28 Mar 2018, 08:47

nnnik wrote:Also using a library name with <> and without it's extension will look for that file in specific folders.
These folders can contain libraries and you can access them from any script without problem.
What defines a library?
  1. A .ahk file with function definitions?
  2. Or a file called myFunction.ahk with only the function definition myFunction() ?
try it and see
...
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: #Include: block auto-include

28 Mar 2018, 09:00

A file containing code thats meant to be used by other scripts.
This is limited to classes or functions.
Recommends AHK Studio
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: #Include: block auto-include

17 May 2018, 21:44

- I thought of a slightly better idea than to simply block any auto-includes.
- The ability to specify which folders to do special searches in, and, if you specify no folders, no special searching is done.
- So, something like #IncludeSearch or #IncludeSpecial (or something else/better).
- It could be that if you use the directive multiple times, it tries the first folder, then the second folder etc.
- Perhaps the directive would override the default searches, rather than add to them.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: #Include: block auto-include

02 Sep 2018, 04:10

- Something like #IncludeDirList: specify which folders to check, blank for none, e.g.
#IncludeDirList %A_ScriptDir%\Lib|%A_MyDocuments%\Lib|%A_AhkDir%\Lib|%A_AhkDir%\Lib\ExtraFuncs
- The variable A_AhkDir would be required.

- Some functions can clutter a Lib folder, so it's good to have extra Lib folders.
- I had this in mind, where each AHK v2 function was backported as a separate ahk file.
GitHub - cocobelgica/AutoHotkey-Future: Port of AutoHotkey v2.0-a built-in functions for AHK v1.1+
https://github.com/cocobelgica/AutoHotkey-Future

[EDIT:] @derz00: My functions tutorial has a section on #Include:
jeeswg's functions tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=41823
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 21 guests