#Include: block auto-include

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

#Include: block auto-include

27 Mar 2018, 18:57

- Sometimes when working with scripts, I can have problems with getting a script to run because I've included a function that depends on another 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 of my script debugging has taken an absolute age.
- Apologies if I have overlooked any existing functionality. Thanks for reading.
User avatar
nnnik
Posts: 2786
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: 648
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
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:
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina SublimeText 3 & AHKv2
User avatar
derz00
Posts: 478
Joined: 02 Feb 2016, 17:54
GitHub: derz00
Location: Middle of the round cube

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: 2786
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] [Download] GeSHi © Codebox Plus

#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: 478
Joined: 02 Feb 2016, 17:54
GitHub: derz00
Location: Middle of the round cube

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: 2786
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: 4267
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.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 6 guests