Re: Capturing current handler name in a string variable
Re: Capturing current handler name in a string variable
- Subject: Re: Capturing current handler name in a string variable
- From: Sander Tekelenburg <email@hidden>
- Date: Tue, 25 Dec 2001 17:57:06 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 19:02 -0600 UTC, on 24-12-2001, billp wrote:
>
[...] is it
>
possible in AppleScript to capture the name of a particular handler or
>
object being referenced at a given time and set it as a string to a
>
variable?
Might something along these lines be useful?
(* beware of line breaks! *)
(* set your variables as before *)
set {theString, theResponse, theIcon, theCount} to {"Let's beep.", "Yeah,
let's.", 1, 2}
(* call your handler and catch its result *)
copy my BeepBeep(theString, theResponse, theIcon, theCount) to {HandlerName,
itsArguments}
(* log your handler's name, and the parameters it received *)
my logHandler(HandlerName, itsArguments)
(* your handler: *)
on BeepBeep(myString, theButton, icon_number, n)
-- set this handler's name to a variable
set myName to "BeepBeep"
--handler does its stuff
display dialog myString buttons {"Cancel", theButton} default button 2 with
icon icon_number
beep n
-- return this handler's name and the arguments it received
return {myName, {myString, theButton, icon_number, n}}
end BeepBeep
on logHandler(HandlerName, itsArguments)
-- do stuff. Like write to file, or display a dialog:
-- coerce arguments to nicer format
set niceArguments to ""
repeat with i in itsArguments
if (class of i = string) or (class of i = text) then
set i to "\"" & i & "\""
end if
set theItem to i & ", "
set niceArguments to niceArguments & theItem
end repeat
set niceArguments to characters 1 thru -3 of niceArguments
display dialog "Handler \"" & HandlerName & "\" was called with these
parameters: " & (niceArguments as string)
end logHandler
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <
http://www.pgp.com>
iQA/AwUBPCivkusywKfXgqKdEQKslACgh5ct2w19rwsvkEHWuKVsUAKfg8wAoLpe
LSSU3vTA9wgIrqmtuJVBhYnW
=JAPu
-----END PGP SIGNATURE-----
--
Sander Tekelenburg