This is fantastic Allen!
Thanks for you fast and generous response! This does exactly I was looking for. Much of the functionality I had in mind was based on my experience with Datebk4 for the Palm and this captures much of the same behaviour I was envisioning.
Is there an easy way to modify your script to specify the category for these new Journal notes? I am not looking to specify the category each time I create a new Journal, I would prefer to simply set a property at the top pf the script that would simply create all Daily Journals in the category called “Business” instead of “None”.
j.
From: Allen Watson <[EMAIL PROTECTED]>
Reply-To: "Entourage:mac Talk" <[EMAIL PROTECTED]>
Date: Tue, 05 Dec 2000 22:44:16 -0800
To: "Entourage:mac Talk" <[EMAIL PROTECTED]>
Subject: Re: Daily Journal ? [Long script]
On or near 12/5/00 6:40 PM, jaywest at [EMAIL PROTECTED] observed:
> I wondering if anyone has any suggestions, strategies or scripts for
> creating daily journals in Entourage? I guess ideally the solution might be
Here you go! The time and date routines are copied from the AppleScript guidebook Help modules. I suggest storing the first script with a name ending in "\smJ" (Cmd-Shift-J), and the second script ending in "\cmJ" (Cmd-Ctrl-J) to assign easy keyboard shortcuts.
First script creates a dated journal note:
set datestmp to format_date_using(current date, "-", {"YYYY", "MM", "DD"})
set timestmp to format_time_using(current date, ":", {"HH", "MM"})
tell application "Microsoft Entourage"
set noteID to make new note with properties {name:"Journal " & datestmp, content:timestmp & return}
open noteID
activate
end tell
on format_date_using(this_date_record, delimiter_string, format_list)
-- get the numeric day
set numeric_day to the day of this_date_record
-- get the month
set month_name to the month of this_date_record
-- convert month to number
set the list_of_months to {January, February, March, April ¬
, May, June, July, August, September, October, November, December}
repeat with i from 1 to 12
if item i of the list_of_months is the month_name then
set the numeric_month to i
exit repeat
end if
end repeat
-- get the numeric year as text
set numeric_year to the year of this_date_record as string
set the formatted_date to ""
-- count the number of items in the list
set the item_count to the count of the format_list
-- parse the format list
repeat with i from 1 to the item_count
set this_item to item i of the format_list
if this_item is "D" then
set the formatted_date to ¬
the formatted_date & numeric_day as string
else if this_item is "DD" then
if the numeric_day is less than 10 then ¬
set numeric_day to ¬
("0" & (the numeric_day as string))
set the formatted_date to ¬
the formatted_date & numeric_day as string
else if this_item is "M" then
set the formatted_date to ¬
the formatted_date & numeric_month as string
else if this_item is "MM" then
if the numeric_month is less than 10 then ¬
set numeric_month to ¬
("0" & (the numeric_month as string))
set the formatted_date to ¬
the formatted_date & numeric_month as string
else if this_item is "YY" then
set the formatted_date to ¬
the formatted_date & ¬
((characters 3 thru 4 of numeric_year) as string)
else if this_item is "YYYY" then
set the formatted_date to ¬
the formatted_date & numeric_year
end if
if i is not the item_count then
-- add delimiter
set the formatted_date to ¬
the formatted_date & delimiter_string as string
end if
end repeat
return the formatted_date
end format_date_using
on format_time_using(this_date_record, delimiter_string, format_list)
set the time_index to the time of this_date_record
set the hour_index to ((the time_index) / hours) div 1
set the minute_index to ¬
(((the time_index) / minutes) - (the hour_index * 60)) div 1
set the seconds_index to ¬
((the time_index) - (the hour_index * 3600) - (the minute_index * 60)) div 1
set the formatted_time to ""
-- count the number of items in the list
set the item_count to the count of the format_list
-- parse the format list
repeat with i from 1 to the item_count
set this_item to item i of the format_list
if this_item is "H" then
set the formatted_time to ¬
the formatted_time & the hour_index as string
else if this_item is "HH" then
if the hour_index is less than 10 then ¬
set hour_index to ¬
("0" & (the hour_index as string))
set the formatted_time to ¬
the formatted_time & hour_index as string
else if this_item is "M" then
set the formatted_time to ¬
the formatted_time & the minute_index as string
else if this_item is "MM" then
if the minute_index is less than 10 then ¬
set minute_index to ¬
("0" & (the minute_index as string))
set the formatted_time to ¬
the formatted_time & minute_index as string
else if this_item is "S" then
set the formatted_time to ¬
the formated_time & the seconds_index as string
else if this_item is "SS" then
if the seconds_index is less than 10 then ¬
set seconds_index to ¬
("0" & (the seconds_index as string))
set the formatted_time to ¬
the formatted_time & seconds_index as string
end if
if i is not the item_count then
-- add delimiter
set the formatted_time to ¬
the formatted_time & delimiter_string as string
end if
end repeat
return the formatted_time
end format_time_using
--- End of first script ---
Second script will open an existing note for today and add a time-stamped entry to it:
set datestmp to format_date_using(current date, "-", {"YYYY", "MM", "DD"})
set timestmp to format_time_using(current date, ":", {"HH", "MM"})
tell application "Microsoft Entourage"
set noteID to note ("Journal " & datestmp)
try
close noteID
on error
try
close window ("Journal " & datestmp)
end try
end try
set t to the content of noteID
set t to t & return & timestmp & return
set content of noteID to t
open noteID
activate
end tell
on format_date_using(this_date_record, delimiter_string, format_list)
-- get the numeric day
set numeric_day to the day of this_date_record
-- get the month
set month_name to the month of this_date_record
-- convert month to number
set the list_of_months to {January, February, March, April ¬
, May, June, July, August, September, October, November, December}
repeat with i from 1 to 12
if item i of the list_of_months is the month_name then
set the numeric_month to i
exit repeat
end if
end repeat
-- get the numeric year as text
set numeric_year to the year of this_date_record as string
set the formatted_date to ""
-- count the number of items in the list
set the item_count to the count of the format_list
-- parse the format list
repeat with i from 1 to the item_count
set this_item to item i of the format_list
if this_item is "D" then
set the formatted_date to ¬
the formatted_date & numeric_day as string
else if this_item is "DD" then
if the numeric_day is less than 10 then ¬
set numeric_day to ¬
("0" & (the numeric_day as string))
set the formatted_date to ¬
the formatted_date & numeric_day as string
else if this_item is "M" then
set the formatted_date to ¬
the formatted_date & numeric_month as string
else if this_item is "MM" then
if the numeric_month is less than 10 then ¬
set numeric_month to ¬
("0" & (the numeric_month as string))
set the formatted_date to ¬
the formatted_date & numeric_month as string
else if this_item is "YY" then
set the formatted_date to ¬
the formatted_date & ¬
((characters 3 thru 4 of numeric_year) as string)
else if this_item is "YYYY" then
set the formatted_date to ¬
the formatted_date & numeric_year
end if
if i is not the item_count then
-- add delimiter
set the formatted_date to ¬
the formatted_date & delimiter_string as string
end if
end repeat
return the formatted_date
end format_date_using
on format_time_using(this_date_record, delimiter_string, format_list)
set the time_index to the time of this_date_record
set the hour_index to ((the time_index) / hours) div 1
set the minute_index to ¬
(((the time_index) / minutes) - (the hour_index * 60)) div 1
set the seconds_index to ¬
((the time_index) - (the hour_index * 3600) - (the minute_index * 60)) div 1
set the formatted_time to ""
-- count the number of items in the list
set the item_count to the count of the format_list
-- parse the format list
repeat with i from 1 to the item_count
set this_item to item i of the format_list
if this_item is "H" then
set the formatted_time to ¬
the formatted_time & the hour_index as string
else if this_item is "HH" then
if the hour_index is less than 10 then ¬
set hour_index to ¬
("0" & (the hour_index as string))
set the formatted_time to ¬
the formatted_time & hour_index as string
else if this_item is "M" then
set the formatted_time to ¬
the formatted_time & the minute_index as string
else if this_item is "MM" then
if the minute_index is less than 10 then ¬
set minute_index to ¬
("0" & (the minute_index as string))
set the formatted_time to ¬
the formatted_time & minute_index as string
else if this_item is "S" then
set the formatted_time to ¬
the formated_time & the seconds_index as string
else if this_item is "SS" then
if the seconds_index is less than 10 then ¬
set seconds_index to ¬
("0" & (the seconds_index as string))
set the formatted_time to ¬
the formatted_time & seconds_index as string
end if
if i is not the item_count then
-- add delimiter
set the formatted_time to ¬
the formatted_time & delimiter_string as string
end if
end repeat
return the formatted_time
end format_time_using
--
Peace,
Allen Watson <[EMAIL PROTECTED]> XNS name: =Allen Watson
A Mac family since 1984 <http://home.earthlink.net/~allenwatson/>
Applescripts for Outlook Express and Entourage: <http://homepage.mac.com/allenwatson/>
