Re: [Newbie Q] How to implement toggle switch? (Now: handlers)
Re: [Newbie Q] How to implement toggle switch? (Now: handlers)
- Subject: Re: [Newbie Q] How to implement toggle switch? (Now: handlers)
- From: email@hidden
- Date: Fri, 7 Jun 2002 15:59:50 EDT
Erik,
Yes, a handler does not have to return a value (even if it did, you could
always return junk data that gets ignored). It can perform operations and/or
return a value (calculated or received from an application via a call). If
the variables it works on are global to the entirety of the script, then when
they are modified within a handler, they are modified for the whole script
and don't need to be returned (or: how to get around passing back only one
variable).
You might want to take a look at the following script to see handler usage
(with extensive commenting), including recursion (a handler calling another
instance of itself):
http://www.cyberpoet.net/as/file_renamers/Recursive_Renamer_v1.21.hqx
Handlers traditionally appear below the main code body (like in C/C++), and
as far as I know, must appear there. As far as I know, each handler called by
another handler must appear above the calling one (i.e. - if GetCharFromASCII
is used by SortTheStack, GetCharFromASCII must appear above SortTheStack in
the listings). I'm not sure if this is absolute, but I'm sure someone on the
list will either confirm or correct this statement.
Best Wishes,
Marc Glasgow
In a message dated 6/7/02 10:14:51 AM, email@hidden writes:
>
So, as with other scripting languages, you can use this
>
handler/subroutine/function to either return a value OR to perform a
>
collection of code. It doesn't have to be a true function (returns a
>
value) or a true subroutine (just executes a chunk of code).
>
>
Last question -- does it have to be at the bottom of the script? Can I
>
put the handler definition at the top? It feels better for me that way.
>
>
Erik
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.