Re: Parents/Child Scripts
Re: Parents/Child Scripts
- Subject: Re: Parents/Child Scripts
- From: Philip Aker <email@hidden>
- Date: Tue, 14 May 2002 07:59:26 -0700
Paul Skinner wrote:
on display dialog (parameters)
[..]
end display dialog
Protestations aside, I see this method as being valuable on a
number of levels. First of all, the fact that it permits the
simplest usage to be simple and more complex usages to be
consistent. Although I haven't tried it yet, I would think that
there would be an easier time when calling from C++ to supply a
fixed length record. And then there's the fact that you can have
it deal with various types of input.
Here's a variant. It adds 'default answer', 'giving up after',
an optional beep, and handles strings, records, aliases, Unicode
text, and lists without having to coerce up front.
on display dialog (theParams)
set b to {"OK"}
set d to last item of b
set i to note
set g to 0
set s to false
if (class of theParams is script) then return ""
if (class of theParams is alias) then
try
set m to (theParams as string)
on error errstr number errnum
return {errstr, errnum}
end try
return continue display dialog m buttons b default button d
with icon i giving up after g
end if
if (class of theParams) is string then
if (count of theParams) is 0 then return ""
set m to theParams
return continue display dialog m buttons b default button d
with icon i giving up after g
end if
if (class of theParams is record) then
try
try
set m to m of theParams
if (class of m is list) then
set lcount to count of m
repeat with x from 1 to lcount
if (class of (item x of m) is record) then
set (item x of m) to ((item x of m) as list)
end if
end repeat
end if
if (class of m is Unicode text) then
set m to m as string
end if
on error
try
set m to +class ktxt; of theParams
on error
set m to ""
end try
end try
try
set b to b of theParams
on error
set b to {"OK"}
end try
try
set a to a of theParams
on error
set a to null
end try
try
set d to d of theParams
on error
set d to last item of b
end try
try
set i to i of theParams
on error
set i to caution
end try
try
set g to g of theParams
on error
set g to 0
end try
try
set s to s of theParams
on error
set s to false
end try
on error errstr number errnum
return {errstr, errnum}
end try
if (s is true) then beep
if a is null then
return continue display dialog m as string buttons b default
button d with icon i giving up after g
else
return continue display dialog m as string default answer a
buttons b default button d with icon i giving up after g
end if
end if
if (class of theParams is list) then
set params to theParams
set lcount to count of params
repeat with x from 1 to lcount
if (class of (item x of params) is record) then
set (item x of params) to ((item x of params) as list)
end if
end repeat
set txt to (every item of params) as string
if (s is true) then beep
return continue display dialog txt buttons b default button d
with icon i giving up after g
end if
if (class of theParams is Unicode text) then
if (count of theParams) is 0 then return ""
set m to theParams as string
return continue display dialog m buttons b default button d
with icon i giving up after g
end if
set what to ((class of theParams) as string)
continue display dialog what
end display dialog
display dialog {m:{{t:"Type", s:space}, "your full name quickly
to win:", return & return, " $US1000.00 tax free cash!" &
return & space}, d:0, a:null, b:{"OK", "OK"}, i:128, s:false,
g:3}
display dialog (path to me)
display dialog (POSIX path of (path to me))
display dialog {m:{"Which path?", return & return, (path to me),
return & return, "or", return & return, (POSIX path of (path to
me))}, d:0, a:null, b:{"OK", "OK"}, i:128, s:false, g:9}
Philip Aker
http://www.aker.ca
_______________________________________________
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.