Zaxon Posted April 28, 2005 Posted April 28, 2005 I have a common library function in which I need to detect whether it has been triggered by an event, or simply called directly in a script. So far, any testing of the macros set during an event, error out the program if used. For instance, an equivalent to IsDeclared(@GUI_WINHANDLE) used for testing variables does not work for testing macros. Nor can you test for @error, since any reference to an event macro will error the program out entirely, causing it to stop. So in summary, I need this functionality: func some_library_routine() if some_test(@GUI_WINHANDLE) then blah else blah endif endfunc where my question is, what test can I use to determine whether this function was triggered via an event, or called directly?
Zaxon Posted April 29, 2005 Author Posted April 29, 2005 I have a common library function in which I need to detect whether it has been triggered by an event, or simply called directly in a script.<{POST_SNAPBACK}>As my question slips onto page 3 of this forum without an answer, do I assume this cannot be done?
Ejoc Posted April 29, 2005 Posted April 29, 2005 You could give it a paramater that you set differently based on how you are calling it: ie Calling it in the script: some_library_routine(0) Calling it from a windows event: $msg = GUIGetMsg() if $msg = $hbutton then some_library_routine(1) Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
Zaxon Posted April 29, 2005 Author Posted April 29, 2005 You could give it a paramater that you set differently based on how you are calling it:ieCalling it in the script:some_library_routine(0)Calling it from a windows event:$msg = GUIGetMsg()if $msg = $hbutton then some_library_routine(1)<{POST_SNAPBACK}>Indeed. I'd thought about that, but I was hoping that my library function could be truly polymorphic, by which I can only achieve that transparency if the function can internally check who called it.Still, if I have no full solutions, then I'll do precisely that, and pass a parameter in manually.Thanks for the input.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now