| 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% |
[ 2 ] |
| \Lib |
|
42% |
[ 8 ] |
| \Include |
|
15% |
[ 3 ] |
| \Includes |
|
0% |
[ 0 ] |
| \Functions |
|
0% |
[ 0 ] |
| Different names even though they're in different locations |
|
31% |
[ 6 ] |
| Other |
|
0% |
[ 0 ] |
|
| Total Votes : 19 |
|
| Author |
Message |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Mon Jun 18, 2007 10:08 pm Post subject: |
|
|
| Skan wrote: | Will there be any built-in variables for these paths ?  | 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 |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6847 Location: Pacific Northwest, US
|
Posted: Mon Jun 18, 2007 10:36 pm Post subject: |
|
|
| 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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Mon Jun 18, 2007 11:21 pm Post subject: |
|
|
| 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 |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6847 Location: Pacific Northwest, US
|
Posted: Mon Jun 18, 2007 11:37 pm Post subject: |
|
|
| 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 |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2436
|
Posted: Tue Jun 19, 2007 1:21 am Post subject: |
|
|
Thanks for making the pre-release version available Chris . Time to take it for a spin .
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Tue Jun 19, 2007 1:29 am Post subject: |
|
|
| corrupt wrote: | Thanks for making the pre-release version available Chris . Time to take it for a spin . | 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 |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2436
|
Posted: Tue Jun 19, 2007 1:40 am Post subject: |
|
|
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?  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Tue Jun 19, 2007 2:19 am Post subject: |
|
|
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 |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2436
|
Posted: Tue Jun 19, 2007 2:27 am Post subject: |
|
|
| 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 . |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Tue Jun 19, 2007 2:28 am Post subject: |
|
|
| Oops, you replied while I was adding a bit more info to the post above. |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2436
|
Posted: Tue Jun 19, 2007 2:35 am Post subject: |
|
|
| 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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Tue Jun 19, 2007 2:47 am Post subject: |
|
|
| 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 |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2436
|
Posted: Tue Jun 19, 2007 2:56 am Post subject: |
|
|
| Thanks. Good to know. |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Jun 19, 2007 3:59 pm Post subject: |
|
|
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
|
Posted: Tue Jun 19, 2007 7:31 pm Post subject: |
|
|
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 |
|
 |
|