Re: AppleScript Timed Events
Re: AppleScript Timed Events
- Subject: Re: AppleScript Timed Events
- From: Simone Manganelli <email@hidden>
- Date: Tue, 17 Jun 2003 18:06:40 -0700
I know all about cron and other utilities that allow you to externally
set an AppleScript to run at a specified time, but I wanted it all to
be encapsulated in an AppleScript, so John's suggestion is the only one
that will do (congratulations, John, you win this awesome new Alfa
Romeo car and a trip to the Caribbean.......). Thanks for all the
suggestions, though.
John: I do have a few more questions, though. You used this code as an
example:
tell app "appname" to set end of agenda to {tstring:"25/12",
_script:"Noel"}
But later you use:
property agenda : {{tstring:"17 jun 03, 9am", _script:"beep.scpt"}}
So what's the format I'm supposed to use so that it registers as an
event? Also, where is the "beep.scpt" located -- can you specify a
path, or can you specify some lines of code that are in the very same
AppleScript file? I wouldn't care for having two different scripts
(one for setting the event, and one for the code to run when the event
occurs).
Basically I just don't understand the syntax on how to use this
particular feature of AppleScript.
-- Simone Manganelli
On Tuesday, Jun 17, 2003, at 03:15 US/Pacific, John Delacour wrote:
At 11:27 pm -0700 16/6/03, Simone Manganelli wrote:
Anybody know how to do timed events with AppleScript? As far as my
knowledge of AppleScript goes (I think it's pretty good, anyway), the
closest thing you can do is an on/end idle loop with a "delay 15"
line or whatever, and then just check for a condition, like a certain
time or date.
I get the feeling you've never actually used it. 'delay' doesn't come
into it, and the idle handler can do everything you need, probably far
more conveniently than the use of any external utility.
You can put a stay-open applet like the one below in your login items.
This applet simply displays the path of the script to run when the
scheduled time has been exceeded; in practice you would add code to
run the script and remove the item from the agenda list or something
like that.
To change the agenda (a list of records) at any time you would simply
send an apple event to change the property or to add to the agenda you
would do
tell app "appname" to set end of agenda to {tstring:"25/12",
_script:"Noel"}
The tstring property of the agenda items is any unambiguous string.
You might like to keep your agenda as tab-delimited text file
tstring1 \t _script1
tstring2" \t _script2
...
and parse this to create the agenda property to send to the applet.
(* STAY OPEN APPLET *)
property agenda : {{tstring:"17 jun 03, 9am", _script:"beep.scpt"}}
property _me : path to me
property _folder : ""
on run
tell app "Finder" to set _folder to "" & container of _me
idle
end run
on idle
set _now to current date
repeat with _record in agenda
set _time to date (tstring of _record)
set _action to _script of _record
if _time is less than _now then
display dialog _folder & _action
end if
end repeat
return 5 * minutes
end idle
--JD
.
_______________________________________________
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.