Re: Parents/Child Scripts
Re: Parents/Child Scripts
- Subject: Re: Parents/Child Scripts
- From: Paul Skinner <email@hidden>
- Date: Mon, 13 May 2002 11:39:51 -0400
On Monday, May 13, 2002, at 03:00 AM, has wrote:
Philip Aker wrote:
--v.interesting folks!
Oh it is, it is. Alas, thanks to AS rotten inconsistent support for
optional parameters it will eventually break your heart. :(
Try:
-------
on display dialog (theText)
continue display dialog theText buttons {"OK"} default button "OK"
with icon note
end display dialog
display dialog "Hello World!" default answer "Hello Joe!"
-------
to see what I mean. And it's worse when the handler requires additional
parameters, e.g. 'display dialog foo default answer bar', because your
script with then barf if your calls _don't_ contain the "optional"
'default
answer' parameter every single time. The only time you can wrap or
replace
an osax call with 100% reliability is when that osax call contains no
optional parameters, eg:
Au contraire mon ami. Opps, I mean Bollocks!
on display dialog (parameters)
if the class of the parameters is string then
set message to the parameters
set buttonlist to {"OK"}
set defaultButton to last item of buttonlist
set IconSpec to 3
else
try
set message to message of parameters
try
set buttonlist to buttonlist of parameters
on error
set buttonlist to {"OK"}
end try
try
set defaultButton to defaultButton of parameters
on error
set defaultButton to last item of buttonlist
end try
try
set IconSpec to IconSpec of parameters
on error
set IconSpec to 3
end try
on error
error "No display text was provided for Display Dialog."
end try
end if
continue display dialog message buttons buttonlist default button
defaultButton with icon IconSpec
end display dialog
display dialog ("Hello World")
display dialog ({message:"Hello World"})
display dialog ({message:"Hello World", buttonlist:{"Push me"}})
display dialog ({message:"Hello World", buttonlist:{"Don't push me",
"Push me"}, IconSpec:1})
display dialog ({message:"Hello World", buttonlist:{"Don't push me",
"Push me"}, defaultButton:"Don't push me", IconSpec:1})
display dialog ({})
Chuffed! ; )
-------
property allTextCharacters : [string of ASCII chars 0-256]
on ASCII character theNumber
try
return item (theNumber + 1) of allTextCharacters
on error
error "Invalid range." number -1720
end try
end ASCII character
ASCII character 100
--> "d"
-------
(going back to the "AsciiNumber & AsciiCharacter Handlers" thread)
Nicely overridden!
Cheers,
has
--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta
AppleScripts
--
Paul Skinner
_______________________________________________
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.