AutoHotkey Community

It is currently May 27th, 2012, 11:11 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: January 26th, 2012, 8:20 pm 
Hi,

Unprefixed library local functions are not recognized when they are called before the prefixed functions.

the manual wrote:
However, such functions should have fairly distinct names because they will still be in the global namespace; that is, they will be callable from anywhere in the script.

Save this as myfunc.ahk in one of the library folders.
Code:
myfunc() {
   msgbox hello
}

funcwithoutprefix() {
   msgbox % A_Thisfunc
}

This runs fine.
Code:
myfunc()
funcwithoutprefix()

However, this doesn't, which I think it should.
Code:
funcwithoutprefix()
myfunc()


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2012, 4:07 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
How will it find the function? Read and parse every file in the Lib folder? That's not how the library mechanism works. It simply #includes a file at load-time based on the name of the function if that function has not been defined.

Either use #include or name your function appropriately.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2012, 6:37 am 
Quote:
How will it find the function?
If that function has not been defined, the reads and parses every file in the Lib folder until it finds it. #AutoInclude or something can be used for this functionality.

Quote:
Either use #include or name your function appropriately.
I don't think that's non-programmer friendly as demonstrated in the initial post.

This is just a suggestion. If you don't find it useful, never mind. However, I'll push it.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group