Re: with timeout / try & on error
Re: with timeout / try & on error
- Subject: Re: with timeout / try & on error
- From: "Stockly, Ed" <email@hidden>
- Date: Tue, 22 May 2007 10:46:40 -0700
- Thread-topic: with timeout / try & on error
>>> While I was attempting to get there though I was testing timeout and
realized this doesn't work
> set x to 0
> with timeout of 1 second
> repeat with i from 1 to 10000000
> set x to x + 1
> end repeat
> end timeout
>> because timeout apparently doesn't work with multiple statements :
That's sort of correct. If any command to an external app within the
multiple statement took more than 1 second, in your example, the script
would timeout with an error. It does not limit the time a block of commands
takes to execute.
Here's my understanding of how timeout works.
When your script sends an appleEvent it waits for a result for the time
specified by the timeout. The default is (I think) 120 seconds.
Some commands don't expect a result, so there is no timeout possible.
Some commands don't generate a timeout error in a particular context, but
will in others.
> with timeout of 1 second
> mount volume "<protocol>://<user>:<pass>@<ip>/<share>"
> end timeout
Try this:
with timeout of 1 second
Tell application "Finder" to mount volume
"<protocol>://<user>:<pass>@<ip>/<share>"
End tell
end timeout
>>> So any idea why timeout isn't working? Any ideas how I can get to my
original goal?
I'm still not sure what your "original goal" is, but looking at your script
try
with timeout of x seconds
-- meat & potatoes
end timeout
on error errMsg number errNUm
-- was hoping to catch any errors or the time out here for
-- log writing purposes
end try
If any single command inside timeout block takes more than x seconds then it
should generate the error.
Does this point you in the right direction?
set thisTime to current date
set dropDeadTime to thisTime + 15
--15 seconds
try
repeat
if (current date) > dropDeadTime then error "Too much time"
--or
--if (current date) > dropDeadTime then exit repeat
end repeat
on error errText
set text item delimiters to return
display dialog {errText, thisTime as string, dropDeadTime as string,
(current date) as string} as string
end try
HTH
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden