AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Include %A_AhkDir% or better comma separated list of include
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Tuncay



Joined: 07 Nov 2006
Posts: 384
Location: Berlin

PostPosted: Sat Jun 09, 2007 5:38 pm    Post subject: Include %A_AhkDir% or better comma separated list of include Reply with quote

If I am writing scripts using "#Include" on my local computer with 5 different partitions, I must take care in which directory my scripts lies. Absolute paths would not help me much, because I copy the scripts to my portable devices (mp3 player, usb-stick), where the drive letter changes frequently.

For example on my USB-Stick I do reference a library that way:
Code:
#Include \lib\xpath.ahk ; The preceding backslash accesses the root drive.


This works perfectly on that device. But what if I copy the script to my local computer? There is the same library, but the path would not be the right one.

I have scripts at my home computer in "%A_AhkPath%\lib" directory, in "D:\" (which represents %A_MyDocuments%), in "E:\Projekte" (Temp, current projects) and finally on my USB-Stick in different directories also. Troubles are preprogrammed.

If only we had "A_AhkDir" (or A_AhkPath) at include command, we could reference to any "standard" folder (of currently interpreted or installed AutoHotkey.exe) we create. That is the same idea of having a standard library directory. Don`t know if there is any difference between the two thoughts (may be easer to implement?).

example:
Code:
#Include %A_AhkDir%\lib\foo.ahk ; A_AhkDir = Current AutoHotkey directory.


or if you don`t want to introducing new variables, change %A_AhkPath% that way to if its used with #Include, so it acts like %A_AhkDir%.

So my current workaround would be that way:
Code:
#Include *i \lib\xpath.ahk ; Portable device.
#Include *i %A_AppDataCommon%\lib\xpath.ahk ; Local computer.


If either files exists, then an error message reporting a conflict of 2 identical function definitions are received. So, that works only on other computers where the "%A_AppDataCommon%\lib\foo.ahk" is not found.

I think that %A_AhkDir% at #Include should be possible and not very complicated to implement, because the AutoHotkey Path is known before execution of script starts. Hope you implement it, its very high priority to me and thus would make my life easier. (Since Ahk its already easier and it becomes more and more easy Smile, v2 would not double, but power it additionally!)

(I do not compile in AutoHotkey!)

Another solution would be to implement a more general request: Comma separated list of includes, using the first found one.

example:
Code:
#Include C:\lib\foo.ahk, %A_ScriptDir%\alternative.ahk ; One of them is required to be included.


<spam>I am fighting here against real life problems. xD</spam>
Back to top
View user's profile Send private message Send e-mail
Tuncay



Joined: 07 Nov 2006
Posts: 384
Location: Berlin

PostPosted: Sat Jun 09, 2007 7:13 pm    Post subject: Reply with quote

Here is an additional thought. The difference between a standard library folder and %A_AhkDir% is simply that all scripts interpreted by any AutoHotkey.exe (launched for example with an bat file, for testing purposes), the standard lib folder would be accessible from any script, regardless of the currently interpreted Autohotkey.exe. Where %A_AhkDir% references naturally the current interpreter.

Thus would us allow making different AutoHotkey environments also.
Back to top
View user's profile Send private message Send e-mail
sanitarium



Joined: 08 Jun 2007
Posts: 28

PostPosted: Sat Jun 09, 2007 7:52 pm    Post subject: Re: Include %A_AhkDir% or better comma separated list of inc Reply with quote

Tuncay wrote:
I think that %A_AhkDir% at #Include should be possible and not very complicated to implement, because the AutoHotkey Path is known before execution of script starts.
I'm actually a bit surprised that A_AhkDir hasn't been implemented as it already exists as a global variable internally in AutoHotkey. I have also found it handy and have quite a few scripts that determine the path based on the path to autohotkey.exe.
Back to top
View user's profile Send private message
Not corrupt as guest
Guest





PostPosted: Sun Jun 10, 2007 12:41 am    Post subject: Reply with quote

Whats wrong w/
Code:
#Include %A_ScriptDir%\INCLUDES
#Include MyScript.ahk
...or...
Code:
SetWorkingDir, %A_ScriptDir%
#Include .\INCLUDES\MyScript.ahk
Razz
Back to top
sanitarium



Joined: 08 Jun 2007
Posts: 28

PostPosted: Sun Jun 10, 2007 1:47 am    Post subject: Reply with quote

Not corrupt as guest wrote:
Whats wrong w/
Code:
#Include %A_ScriptDir%\INCLUDES
#Include MyScript.ahk
...or...
Code:
SetWorkingDir, %A_ScriptDir%
#Include .\INCLUDES\MyScript.ahk
Razz
The difference is obvious. The script's directory is not necessarily AutoHotkey's directory as has been requested. Try to read next time...
Back to top
View user's profile Send private message
Not corrupt as guest
Guest





PostPosted: Sun Jun 10, 2007 2:26 am    Post subject: Reply with quote

Oh.. sorry.
Code:
SetWorkingDir, %A_AhkDir%
#Include .\INCLUDES\MyScript.ahk
Back to top
sanitarium



Joined: 08 Jun 2007
Posts: 28

PostPosted: Sun Jun 10, 2007 3:29 am    Post subject: Reply with quote

Not corrupt as guest wrote:
Oh.. sorry.
Code:
SetWorkingDir, %A_AhkDir%
#Include .\INCLUDES\MyScript.ahk
Again, perhaps read carefully. A built-in A_AhkDir variable doesn't currently exist in AutoHotkey code. An A_AhkPath variable does but that includes the name of the .exe and not just the directory name. That was the whole point.


@Not corrupt as guest: Since I can't send you a PM...
Btw, is that grumpy enough for ya or would you prefer me to start mixing in a bit of profanity and be a bit more insulting in the process? If that sounds great then click here (warning: not appropriate for children) Since you seem to like definitions, be sure to check out the .mp3 file too if you decide to check out the url.
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2397

PostPosted: Sun Jun 10, 2007 7:20 am    Post subject: Reply with quote

@Not corrupt as guest - strange choice for a guest nick...
Back to top
View user's profile Send private message Visit poster's website
Not corrupt as guest
Guest





PostPosted: Sun Jun 10, 2007 8:07 am    Post subject: Reply with quote

Corrupt-- you crack me up. You really need to be more selective in picking your battles; I whole heartly agree that a better more intuitive method for creating/referencing structs needs to be implemented.. but you know as much as I know that the Chris's current focus is in implementing "mechanisms" for a standard library (whatever they may end up being..). There is absolutely no point to fight over something that already has an easy two-three line solution.

There has been quite a bit of negative energy floating around now adays. Its discouraging to hear a lot of the posts as of lately from the most respected forum gurus; You have provided several indespensible AHK based scripts/solutions that I to this day learn from & admire what you have done. The choice in Username wasn't to offend.. but to make light of your recent name change. Smile

What really concerns me (as a user of AHK since its conception..) is that with so many demands-- Chris seems to be overwelmed.. & more importantly seems to be loosing interest in trying to keep up w/ the demands on this scripting language.

PS. I'm sorry if I pissed you off. Crying or Very sad
PSS. I'm not the original 'Grumpy' author that pissed you off yesterday.
Back to top
sanitarium



Joined: 08 Jun 2007
Posts: 28

PostPosted: Sun Jun 10, 2007 8:51 am    Post subject: Reply with quote

Not corrupt as guest wrote:
but you know as much as I know that the Chris's current focus is in implementing "mechanisms" for a standard library (whatever they may end up being..). There is absolutely no point to fight over something that already has an easy two-three line solution.
I agree and agree that when/if a Standard Library ever gets implemented (I'm not holding my breath waiting for it to be in the next release - it's been a couple years now after many discussions) that it could solve this issue. I think you might have missed the point in this particular suggestion/topic though. Since #Include lines are processed before the script starts executing and since an A_AhkDir variable doesn't currently exist and isn't supported by #Include, there is no current workaround available.

Not corrupt as guest wrote:
There has been quite a bit of negative energy floating around now adays. Its discouraging to hear a lot of the posts as of lately from the most respected forum gurus;
I don't consider myself to be a guru but thanks. I can't speak for other people here but the lack of support when trying to build add-ons to enhance features and/or provide additional functionality is discouraging.

Not corrupt as guest wrote:
What really concerns me (as a user of AHK since its conception..) is that with so many demands-- Chris seems to be overwelmed.. & more importantly seems to be loosing interest in trying to keep up w/ the demands on this scripting language.
I'm aware and there's likely a few things you aren't aware of if you're pointing this out to me.

Not corrupt as guest wrote:
PS. I'm sorry if I pissed you off. Crying or Very sad
PSS. I'm not the original 'Grumpy' author that pissed you off yesterday.
I honestly don't know who the original Grumpy guest was/is. Unfortunately the concept of people using an alias to say things that they likely wouldn't with their registered names seems common around here...

PS - It's generally better to be pissed off than on when unaware... Laughing Twisted Evil
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Jun 12, 2007 9:10 pm    Post subject: Reply with quote

A standard library mechanism is planned for the next release. The basic design is that any reference to a nonexistent function such as MyFunc() looks for a filename called "MyFunc.ahk" in:

- The %A_MyDocuments%\AutoHotkey\Includes folder.
- And if not found there, it looks in the AutoHotkey\Includes folder.

If the file exists, it is automatically loaded.

If after the next release you still find that there are essential features missing from #Include, please restate remaining/missing features (more concisely if possible).

Thanks.
Back to top
View user's profile Send private message Send e-mail
Titan



Joined: 11 Aug 2004
Posts: 5068
Location: imaginationland

PostPosted: Tue Jun 12, 2007 9:16 pm    Post subject: Reply with quote

Chris wrote:
- The %A_MyDocuments%\AutoHotkey\Includes folder.
Can that be changed in the registry? I use My Documents\Scripts and I'm reluctant to change in case I have hard coded paths etc. Sorry I haven't been following the stdlib discussions much.
_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Jun 12, 2007 9:23 pm    Post subject: Reply with quote

It is planned to be changeable on a per-script basis. There is no plan to support the registry; but that might happen someday.
Back to top
View user's profile Send private message Send e-mail
Tuncay



Joined: 07 Nov 2006
Posts: 384
Location: Berlin

PostPosted: Tue Jun 12, 2007 9:24 pm    Post subject: Reply with quote

I dont like the registry, because of some usb-stick portable reasons.

May be its time to introduce an INI-File (AutoHotkey.ini) for some settings found in AutoHotkey Folder to change some of the configurations like this?

Edit:
Won`t be a standard libaray delivered with AutoHotkey distribution? Why not taking the stdlib folder under AutoHotkey`s directory (at default)?
Back to top
View user's profile Send private message Send e-mail
corrupt



Joined: 29 Dec 2004
Posts: 2397

PostPosted: Wed Jun 13, 2007 6:10 am    Post subject: Reply with quote

Tuncay wrote:
Edit:
Won`t be a standard libaray delivered with AutoHotkey distribution? Why not taking the stdlib folder under AutoHotkey`s directory (at default)?
If I understood correctly, the main reason is to allow a user to easily add files to the directory (in Vista, Program Files directories would require Admin access) and to allow a user to override a StdLib function without having to modify the Library (which the user may not have permissions for).
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group