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 

A_CallerFunc

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Piz



Joined: 16 Feb 2008
Posts: 46

PostPosted: Wed Feb 27, 2008 2:40 am    Post subject: A_CallerFunc Reply with quote

In the same vein as A_ThisFunc, how about A_CallerFunc?* Not the current function, but the one that called the current function.

*I'm not married to the name, just illustrating the idea.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5697

PostPosted: Wed Feb 27, 2008 8:41 am    Post subject: Reply with quote

Code:
Func1( "Hello" )

Func1( Str ) {
 Func2( Str, A_ThisFunc )


Func2( Str, A_CallerFunc ) {
 MsgBox,0, %A_CallerFunc%, %Str%
}


Am I missing something ? Rolling Eyes
Back to top
View user's profile Send private message
Piz



Joined: 16 Feb 2008
Posts: 46

PostPosted: Wed Feb 27, 2008 12:58 pm    Post subject: Reply with quote

SKAN wrote:
Am I missing something ? Rolling Eyes

A bit. Smile I want to avoid having to pass A_ThisFunc as a parameter in order for a function to know what called it:
Code:
Func1("Hello")

Func1(str)
   {
   Func2(str)
   }

Func2(str)
   {
   msgBox 0, %A_CallerFunc%, %Str%
   }

With the new capability I'm suggesting, the above will produce the same result as yours. (Of course at present it won't work.)
Back to top
View user's profile Send private message
Tuncay



Joined: 07 Nov 2006
Posts: 383
Location: Berlin

PostPosted: Sun Mar 02, 2008 7:49 pm    Post subject: Reply with quote

I have same thoughts about a built-in A_CallerFunc. The user should not need to pass A_ThisFunc or know about this.
Back to top
View user's profile Send private message Send e-mail
ManaUser



Joined: 24 May 2007
Posts: 900

PostPosted: Mon Mar 03, 2008 12:21 am    Post subject: Reply with quote

I'm having a hard time imagining when you would use this. Honestly it doesn't seem like a very good idea to make a function that "cares" where it's called from. It would be more confusing than useful IMHO. Though I'm curious to hear what you would use this feature for if you had it.
Back to top
View user's profile Send private message
Piz



Joined: 16 Feb 2008
Posts: 46

PostPosted: Mon Mar 03, 2008 12:50 am    Post subject: Reply with quote

ManaUser wrote:
I'm having a hard time imagining when you would use this. Honestly it doesn't seem like a very good idea to make a function that "cares" where it's called from. It would be more confusing than useful IMHO. Though I'm curious to hear what you would use this feature for if you had it.
It could be useful for debugging and maintaining log files, to name two simple examples.

Let me turn it around on you - why would you write a function that requires you to pass in A_ThisFunc as a parameter? And if there's no reason to do that, why have A_ThisFunc at all?
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1332

PostPosted: Mon Mar 03, 2008 12:53 am    Post subject: Reply with quote

Quote:
why have A_ThisFunc at all?


you shouldnt Wink
Back to top
View user's profile Send private message
ManaUser



Joined: 24 May 2007
Posts: 900

PostPosted: Mon Mar 03, 2008 1:49 am    Post subject: Reply with quote

Piz wrote:
Let me turn it around on you - why would you write a function that requires you to pass in A_ThisFunc as a parameter? And if there's no reason to do that, why have A_ThisFunc at all?

Now that you mention it, I can't think of a real good reason for that either. It was probably added mostly because there was already A_ThisLabel and A_ThisHotkey.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
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