Re: Question about handler efficiency
Re: Question about handler efficiency
- Subject: Re: Question about handler efficiency
- From: email@hidden
- Date: Tue, 6 Feb 2001 04:05:55 EST
Bill,
Once again I find myself confused by your terminology. Maybe its just me.
What you wrote:
>
My question is this: would it be smart/efficient to combine several of
>
these handlers into the same handler (say "TextHandler"), just with
>
different tags calling the different appropriate portion. For example:
I would re-write as:
My question is this: would it be smart/efficient to combine several of these
handlers into the same script object (say "TextHandler"), while of course
assigning unique handler names within that script object?
The answer to this question would be ABSOLUTELY YES.
A "handler" (as opposed to a script object) is something that looks like:
on callThisHandler()
-- do stuff
end callThisHandler
A script object can and probably should have multiple handlers. Combining
handlers into one *script* (to be loaded as a script object) is good
practice. Combining them into one *handler* may or may not make sense
depending on exactly what the handlers do and how they are used, but in most
cases that would not be a good plan.
Additionally, there is no reason to call one handler from one tell block, and
the other from a separate tell block. In fact, they can be called from the
same line if necessary:
set x to TellHandler's replaceText(replaceCase(oldText,newText),newerText)
Finally, I use the term "tags" when referring to HTML, not when referring to
programming constructs.
HTH!
Jeff Baumann
email@hidden
www.linkedresources.com
Comparing MHz between the G4 and Pentium is like comparing the popular vote
between Bush and Gore; it's interesting, but it isn't what matters.
In a message dated 2/6/01 12:21:14 AM, Bill Planey wrote:
>
I have a question about handlers. I have a variety of handlers that load
>
for different search/replace circumstances in MSWord (the handlers make
>
calls to Visual Basic, and since those calls are by nature very wordy,
>
they save me a lot of trouble.
>
>
My question is this: would it be smart/efficient to combine several of
>
these handlers into the same handler (say "TextHandler"), just with
>
different tags calling the different appropriate portion. For example:
>
>
on ReplaceText(oldText, newText)
>
-- do stuff, invoking oldText and newText
>
end ReplaceText
>
>
on ReplaceCase(oldText, newText)
>
-- do stuff, invoking oldText and newText
>
end ReplaceCase
>
>
...so that in the Script which uses TextHandler its different parts could
>
be invoked thus:
>
>
tell TextHandler
>
ReplaceText("FindString", "ReplaceString") -- where "FindString" and
>
-- "ReplaceString" are stated in the script
>
ReplaceText("FindString", "ReplaceString")
>
ReplaceText("FindString", "ReplaceString") -- etc.
>
end tell
>
>
tell TextHandler
>
ReplaceCase("FindString", "ReplaceString")
>
ReplaceCase("FindString", "ReplaceString")
>
ReplaceCase("FindString", "ReplaceString") -- etc.
>
end tell
>
>
...or would it be better to keep them as they are now, separated into
>
different scripts, and loaded separately (which takes several more
>
statements to articulate)?
>
>
Thanks,
>
>
Bill Planey