Re: assistance with script
Re: assistance with script
- Subject: Re: assistance with script
- From: Kai <email@hidden>
- Date: Wed, 12 Mar 2003 02:08:00 +0000
on Mon, 10 Mar 2003 20:25:13 -0500, Ross Hunter wrote:
>
I've included my scripting efforts below. I use Eudora. I have placed
>
my script in the startup folder so it checks email when the computer
>
comes on in the morning.
I don't use Eudora, Ross - although I do run a few automatic routines on
startup every day.
>
The script does not quit properly. When I shut down the computer I
>
get a window saying the script has timed out and I have to click
>
"OK". I'd like to know how to properly end the script so that I can
>
start the shutdown process and walk away from the computer.
When AppleScript sends a command to an application, it normally waits for
the command to complete execution before continuing with the rest of the
script. If the command takes longer to complete than the default timeout
(one minute), AppleScript stops running the script and returns the error
"event timed out".
You can avoid timeout errors by extending the time that AppleScript is
prepared to wait for the command to complete execution:
===============================
with timeout of 1000000 seconds
tell application "some app" to do something
end timeout
===============================
Don't worry about setting too lengthy a timeout. The script will continue as
soon as the command has been executed. (If you set too short a timeout,
there's always the risk that you'll get another timeout error.)
If you don't need a result to be returned from the application command, and
you'd prefer the script to continue without waiting for a result, then you
might try this instead:
===============================
ignoring application responses
tell application "some app" to do something
end ignoring
===============================
>
You can see at the top of my script, my crude first efforts to make
>
the script so it will only run when the computer starts up at 7 in
>
the morning. I have not yet figured out how to make it "tell time".
I use a slightly different technique to yours. Instead of checking to see if
the current time is between a start and end time, my script simply sets the
date and time after which the script should re-run.
If for some reason the machine doesn't startup at the regular time, the
script will try to catch up by running the required routines at the next
startup - whether it happens to be at the normal time or not. (This may or
may be what you require - but it does demonstrate an alternative method.)
===============================
property tomorrow : (current date) - days
set today to current date
if today > tomorrow then
set {tomorrow, tomorrow's time} to {today + days, 21600}
-- [do stuff required on first startup only]
end if
===============================
The above script is intended to take any specified actions the first time it
runs after 6 am. It also resets the next run to trigger after 6 am on the
following day.
If you want to calculate times, then try using AppleScript's time constants
(minutes / hours / days / weeks) like this:
6 * hours --> 21600
6 * hours + 55 * minutes --> 24900
7 * hours + 5 * minutes --> 25500
>
The script seems to run properly from "tell application "Finder"
>
through the "end tell" after "connect with checking".
As far as I can see, you shouldn't really need any of the Finder stuff at
all. (I've suggested a modified version after your script, below.)
>
-----------------------------------------------
>
-- set the time_slug to my format_time_using(the current date, ":",
>
{"HH", "MM"})
>
-- set the time to time_slug
>
--if time_slug is greater than "06 55 " and time_slug is less than "07 05"
then
>
tell application "Finder"
>
activate
>
select startup disk
>
open selection
>
select folder "Internet" of startup disk
>
open selection
>
select file "Eudora" of folder "Eudora Application Folder" of
>
folder "Internet Applications" of folder "Internet" of startup disk
>
open selection
>
end tell
>
tell application "Eudora"
>
connect with checking
>
end tell
>
tell application "Finder"
>
return
>
end tell
>
-- end if
>
-- tell application "Control PPP"
>
-- quit
>
-- end tell
>
--__--__--
Obviously I can't test with Eudora (or your system), but you might try
something like this:
===============================
tell (current date)'s time to if it > 24900 and it < 25500 then
ignoring application responses
tell application "Eudora" to connect with checking
end ignoring
end if
===============================
(If it doesn't work for you, let me know - it may just require minor
tweaking.)
--
Kai
_______________________________________________
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.