Re: With Timeout
Re: With Timeout
- Subject: Re: With Timeout
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 05 Aug 2002 11:28:33 -0700
On 8/5/02 11:08 AM, "email@hidden" <email@hidden> wrote:
>
Has with timeout ever worked?
>
I'm trying it on 10.2, 10.1, and 9.2, and I can't seem to get the following
>
to work:
>
>
with timeout 10 seconds
>
display dialog "Text" default anser "reply"
>
end timeout
>
>
The dialog comes up and sits there forever. I can't get it to error out
>
after the specified 10 seconds.
>
>
Any ideas?
The best idea is to first read up on it in the AppleScript Language Guide,
That's what it's there for:
p. 272
A With Timeout statement lets you change how long AppleScript waits before
stopping execution of a script. The amount of time you specify in a With
Timeout statement applies to some types of commands within the statement
that are sent to other applications, but not to any commands sent to the
application that9s running the script.
p. 273
By default, AppleScript waits one minute for a response before stopping
execution of application and scripting addition commands that are sent to
other applications. A With Timeout statement lets you change how long
AppleScript waits.
It only works when you send commands to other applications. You're not doing
that.
with timeout of 10 seconds
tell application "Finder"
activate
display dialog "Text" default answer "reply"
end tell
end timeout
will work. it will also give you an error "Apple Event timed out". You'd
have to do this to avoid that:
try
with timeout of 10 seconds
tell application "Finder"
activate
display dialog "Text" default answer "reply"
end tell
end timeout
end try
BUT: if all you're concerned with is ending a display dialog, then there's a
much better way. 'display dialog' (ever since OS 8.6 or so, maybe 9.0) has a
'giving up after' parameter. No need to direct to another application
either:
display dialog "Text" default answer "reply" giving up after 10
(You do need to spell "answer" correctly, however.)
--
Paul Berkowitz
_______________________________________________
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.