Shirt Pocket Discussions

Shirt Pocket Discussions (http://www.shirt-pocket.com/forums/index.php)
-   General (http://www.shirt-pocket.com/forums/forumdisplay.php?f=6)
-   -   applescript help (http://www.shirt-pocket.com/forums/showthread.php?t=673)

snoopy67 09-14-2005 05:25 AM

applescript help
 
Could some kind soul fluent in Applescript please translate the following csh-stylish statement for me?

I would like to write something like this in an applescript:

if ( date since this script was run last time is more than a week ago )
then
... do this
else
if ( this script was run today already )
then
... do that
else
... do that other
endif
endif

In addition, i would like to have a persistent counter which i can increment and reset (persistent across different runs of the script).
I suspect that's achieved by using a "property"?


I know it's a bit cheap to just ask here, and yes, i know you might be thinking that i should learn applescript, but i simply don't have the time, and i won't be using it often enough to justiy the time to learn it.

Many thanks in advance,
Gabriel.

darelon 09-17-2005 10:07 AM

Gabriel,

If you haven't found a way yourself yet, you might try something like this:

Code:

property lastRunDate : date "1/1/1"
property persistentCounter : 0

set currentDate to current date

if (currentDate > lastRunDate + 7 * days) then
        log "do this"
else if (short date string of currentDate is short date string of lastRunDate) then
        log "do that"
else
        log "do that other"
end if

set lastRunDate to currentDate
set persistentCounter to persistentCounter + 1

HTH,
Ciao,
Roeland.


All times are GMT -4. The time now is 06:10 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.