Re: Getting a handler to use a value from a different handler?
Re: Getting a handler to use a value from a different handler?
- Subject: Re: Getting a handler to use a value from a different handler?
- From: Christopher Nebel <email@hidden>
- Date: Tue, 18 Oct 2005 13:13:25 -0700
On Oct 18, 2005, at 12:33 PM, Michelle Steiner wrote:
Chris, I have a few questions about style, if I may.
On Oct 18, 2005, at 8:20 AM, Christopher Nebel wrote:
on AskTitle()
set d to display dialog "Title:" default answer ""
Why bother with "set d" if the script doesn't use the variable "d"?
set answer to text returned of the result
return answer
end
For that matter, why not this:
return (text returned of (display dialog "Title:" default answer ""))
Oops. As you might have guessed, I originally wrote that function
more or less as you finally suggested. However, I decided that since
the OP seemed to understand variables but not function return values,
it would be better to be a bit more long-winded about it.
Unfortunately, I missed part of the transformation, hence the unused
"d". It should have read
on AskTitle()
set d to display dialog "Title:" default answer ""
set answer to text returned of d
return answer
end
on ReplaceText(replacement_text)
(* magic goes here *)
end
on run
set replacement_string to AskTitle()
ReplaceText(replacement_string)
end
And why not this:
replaceText (askTitle())
Same reason. The original question was phrased in terms of the
"replacement_string" variable, so I kept it around. Besides, he
implied that he'd have to call several different functions with the
return value of AskTitle(), in which case the variable is clearly
necessary.
While some coding style has a real purpose, namely maintainability,
some style is just, well, style. It doesn't do to slavishly imitate
others' styles without understanding the reasons why it matters (or
doesn't); otherwise, you get cargo cult programming.
--Chris Nebel
AppleScript and Automator Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden