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 

Standard/User libraries for automatic function inclusion
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  

What should be the names of the standard- and user-library directories? (Regardless of the name, they are SEPARATE directories in two different locations.)
\Library
10%
 10%  [ 2 ]
\Lib
42%
 42%  [ 8 ]
\Include
15%
 15%  [ 3 ]
\Includes
0%
 0%  [ 0 ]
\Functions
0%
 0%  [ 0 ]
Different names even though they're in different locations
31%
 31%  [ 6 ]
Other
0%
 0%  [ 0 ]
Total Votes : 19

Author Message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Mon Jun 18, 2007 10:08 pm    Post subject: Reply with quote

Skan wrote:
Will there be any built-in variables for these paths ? Rolling Eyes
There will probably be some way to refer to them and/or customize them in the future. But that will require a bit more discussion.

In the meantime, when #Include is used inside a library function, it uses that library's directory as its default (though I'm not sure if this capability will be commonly used). Also, class names are possible by calling MyPrefix_MyFunction(), in which case MyPrefix.ahk is loaded (which presumably contains several functions, only one of which is MyPrefix_MyFunction).
Back to top
View user's profile Send private message Send e-mail
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Mon Jun 18, 2007 10:36 pm    Post subject: Reply with quote

Chris wrote:
Also, class names are possible by calling MyPrefix_MyFunction(), in which case MyPrefix.ahk is loaded (which presumably contains several functions, only one of which is MyPrefix_MyFunction).


This sounds great, but I have a question

so MyPrefix file should contain a function called MyPrefix_MyFunction, or just MyFunction?

Also, I assume _ is the delimiter?

MyPrefix.ahk
Code:

MyPrefix_MyFunction(a)
Return a

MyPrefix_MyFunction2(a)
Return a


This seems fine, I just wanted to be clear. It would be kind of handy to allow this:

MyPrefix.ahk
Code:

MyFunction(a)
Return a

MyFunction2(a)
Return a


but still called by MyPrefix_Myfunction()

Thanks!
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Mon Jun 18, 2007 11:21 pm    Post subject: Reply with quote

engunneer wrote:
so MyPrefix file should contain a function called MyPrefix_MyFunction, or just MyFunction?
Each function definition in the file must have the prefix too (assuming that's how the caller will call it).

engunneer wrote:
It would be kind of handy to allow this:

MyPrefix.ahk
Code:
MyFunction(a)
Return a

MyFunction2(a)
Return a
but still called by MyPrefix_Myfunction()
Interesting idea, but it would lead to problems if the file is ever explicitly included (or copied and pasted to make it independent from the library). Plus it would force all functions in the file to start with the prefix, which the author of the file might not want (e.g. for private functions that are only called internally by the functions in that file, etc.). In general, I think it would cause more trouble than it's worth.

Another drawback is the added code complexity: Both ahk2exe and AutoHotkey.exe would have to be altered to prepend the prefix to all the functions. This could be quite difficult in the case of ahk2exe because it currently has no ability to recognize function calls or definitions.
Back to top
View user's profile Send private message Send e-mail
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Mon Jun 18, 2007 11:37 pm    Post subject: Reply with quote

Chris wrote:
Plus it would force all functions in the file to start with the prefix, which the author of the file might not want (e.g. for private functions that are only called internally by the functions in that file, etc.).

I think it shouldn't require that, since now that the file is inculded, the function calls will resolve before it searches the Library.

Chris wrote:

In general, I think it would cause more trouble than it's worth.

Another drawback is the added code complexity: Both ahk2exe and AutoHotkey.exe would have to be altered to prepend the prefix to all the functions. This could be quite difficult in the case of ahk2exe because it currently has no ability to recognize function calls or definitions.


Probably would be a mess, and a pain to explain, to boot. I agree completely, but it was just a thought.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Tue Jun 19, 2007 1:21 am    Post subject: Reply with quote

Thanks for making the pre-release version available Chris Smile . Time to take it for a spin Very Happy .

Out of curiosity, would that make an underscore character illegal in a standard lib file name? Also, are only alpha numeric characters acceptable for function names/standard library file names as previous suggested?
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Tue Jun 19, 2007 1:29 am    Post subject: Reply with quote

corrupt wrote:
Thanks for making the pre-release version available Chris Smile . Time to take it for a spin Very Happy .
Thanks; it's good to have someone else look at it prior to release.

corrupt wrote:
would that make an underscore character illegal in a standard lib file name?
No, underscores are used only as a last resort lookup when all other searches fail to find the function. There's nothing else special about underscores.

Quote:
Also, are only alpha numeric characters acceptable for function names/standard library file names as previous suggested?
There is currently no restriction; though it is tentatively planned in v2 to be more restrictive about the names of functions and variables, which avoids conflicts with operator symbols (present and future).
Back to top
View user's profile Send private message Send e-mail
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Tue Jun 19, 2007 1:40 am    Post subject: Reply with quote

Does that mean that the only restrictions are what the O/S will let us use for filenames? One of the issues I ran into with pre-processor based stdlib versions was that although AutoHotkey would allow a function name like Struct? or Struct@ the O/S would not allow a filename named Struct?.ahk. How would AutoHotkey deal with searching for a missing function named Struct? Question
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Tue Jun 19, 2007 2:19 am    Post subject: Reply with quote

The illegal characters in Windows filenames are: *? <> " /\| :

Among these, only question marks are allowed in AutoHotkey function names. If a function's name contains a question mark, the program still asks the OS to open it (which of course fails). So there is no support for question marks.

This doesn't seem like that big of a deal because question marks won't be allowed in AutoHotkey v2 (due to the ternary operator). There will probably be a v1-to-v2 translator utility that replaces question marks with some other character like underscore.


Last edited by Chris on Tue Jun 19, 2007 2:29 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Tue Jun 19, 2007 2:27 am    Post subject: Reply with quote

Chris wrote:
If a function's name contains question marks or other characters that are illegal in Windows filenames, there is no support for them. This doesn't seem like that big of a deal because question marks won't be allowed in AutoHotkey v2 (due to the ternary operator).
That sounds ok to me. Thanks for the info Smile .
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Tue Jun 19, 2007 2:28 am    Post subject: Reply with quote

Oops, you replied while I was adding a bit more info to the post above.
Back to top
View user's profile Send private message Send e-mail
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Tue Jun 19, 2007 2:35 am    Post subject: Reply with quote

Chris wrote:
Among these, only question marks are allowed in AutoHotkey function names. If a function's name contains a question mark, the program still asks the OS to open it (which of course fails). So there is no support for question marks.
I may be wrong but I think that it's possible that the O/S might not fail when trying to find a file when searched for using a question mark. A question mark can be used from a cmd prompt. For example, dir autoexe?.bat will list autoexec.bat if it exists in the directory.
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Tue Jun 19, 2007 2:47 am    Post subject: Reply with quote

The program uses GetFileAttributes() to check if the file exists. Since there is no mention of any wildcard support at MSDN, GetFileAttributes() simply reports "not found" when passed a filename containing a question mark (even if a file exists that would match such a wildcard). Testing confirms this, so I'm glad you mentioned it.
Back to top
View user's profile Send private message Send e-mail
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Tue Jun 19, 2007 2:56 am    Post subject: Reply with quote

Thanks. Good to know.
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Tue Jun 19, 2007 3:59 pm    Post subject: Reply with quote

Well just took the new test version for a ride. I was a bit sceptical about the MyClass prefix stuff particularly because i don't want all the functions to have unconvinient long names.
But than i realised i can just create an bogus function an call that and all my stuff gets imported.
For example in MyUberTools.ahk i create a MyUberTools_init() function and call it ones in the autoexecution section of my script.
Now this solves another problem. Initializing variables. I can let MyUberTools_init() initialize variables and let it set Globaloptions as i need them. Sweet.

Chris how is is decided what functions will be part of the stdlib? How is the std lib be gonna be documented?
Back to top
Tuncay



Joined: 07 Nov 2006
Posts: 383
Location: Berlin

PostPosted: Tue Jun 19, 2007 7:31 pm    Post subject: Reply with quote

Is there any plan of a directive that would lead to automatically look with prefix defined? Like namespaces, a default prefix.

For example:
Code:
#Namespace std
getSomething()

searching automatically for std_getSomething().
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 5 of 6

 
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