How to update iCal event summary if it is moved?

Hi,

I decided to put my hand up and write a little app for a farmer that writes into iCal about 100-150 appointments come February each year. It’s to do with ultra-sounding sheep for testing single or multiple pregnancies.

I’ve written the app in ASS and that is working nicely. It essentially, takes the input and writes an event into iCal. One day I might learn ObjC and convert fully.

Anyway, appointments often may clash and so the farmer will resort to physically dragging the appointments inside iCal forwards or backwards by “n” days to achieve a suitable schedule. This is where the farmer asked if the summary of the event could automatically be updated!!

The summary of each event is as follows:

<f_initial>.

Scan for: <single_twins_string>
Rams Introduced: days ago
Rams Free: days

As you can see, I’m wanting and to be recalculated upon the event being moved. The reason for this is that ultra-sounding sheep has an optimum window of days and so the event shouldn’t be moved outside of those days.

I’ve achieved an adhoc method of doing this by using system events to copy the summary of the selected event, split the lines down to usable variables (using paragraph and item) to have the days recalculated, and paste it back over the top of the event summary.

I couldn’t find any other examples to do this.

Is there a programatically means to do this? other than relying on System Events’ copy and paste methods?

Cheers,

Model: intel
AppleScript: 2.1.2?
Browser: Safari 533.19.4
Operating System: Mac OS X (10.6)

Hi,

unfortunately iCal is the only of the iApps which lacks in a selection property.
A solution without GUI scripting could be to display a list of the relevant events.
Then choose the event, ask for the time shift, calculate the relative dates and move the event programmatically

Hi, tanglez. Welcome to MacScripter.

I think what you want is doable with a stay-open applet, but I’m not sure how well the one below fares with hundreds of entries. It makes a note of the uids and current start dates of all the events in a calendar called “Lambing”. Every five seconds or so, it compares the start dates it’s collected with those the events currently have, works out any differences in days, edits the summaries of the affected events accordingly, and refreshes its own UID and start date lists.

I’ve assumed that the “Rams free:” figure is meant to represent the amount of time to a fixed point after the event date. Hope I’ve got that right.

Save this as a stay-open application and have it running in the background while the events are being dragged around in iCal. You’ll undoubtedly want to make alterations. :slight_smile:

property calendarName : "Lambing" -- Your calendar name here.
property idleTime : 5 -- Time (in seconds) between scans. Increase if necessary.

property originalData : missing value

on run
	tell application "iCal"
		activate
		set originalData to {uid, start date} of events of calendar calendarName
	end tell
end run

on idle
	-- Get the script's stored UID and start date lists.
	set {eventUIDs, startDates} to originalData
	
	-- Compare the stored start dates with the ones the events currently have.
	repeat with i from 1 to (count eventUIDs)
		set thisUID to item i of eventUIDs
		set originalStartDate to item i of startDates
		try -- Use a 'try' statement in case this event's been deleted.
			tell application "iCal"
				set thisEvent to (first event of calendar calendarName whose uid is thisUID)
				set currentStartDate to thisEvent's start date
			end tell
			-- If the stored and current start dates for this event are on different days, edit the summary.
			if (currentStartDate is not originalStartDate) then
				set currentStartDate's time to 0
				set originalStartDate's time to 0
				set dayShift to (currentStartDate - originalStartDate) div days
				if (dayShift is not 0) then editSummary(thisEvent, dayShift)
			end if
		end try
	end repeat
	
	-- Refresh the script's stored data.
	tell application "iCal" to set originalData to {uid, start date} of events of calendar calendarName
	
	return idleTime
end idle

on editSummary(thisEvent, dayShift)
	tell application "iCal" to set theSummary to thisEvent's summary
	set theParagraphs to theSummary's paragraphs
	
	set astid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to space
	-- This assumes that the numbers to change are the third words in lines beginning with "Rams".
	repeat with thisParagraph in theParagraphs
		if (thisParagraph begins with "Rams") then
			set theWords to thisParagraph's text items
			if (item 2 of theWords is "Introduced") then
				set newDays to (item 3 of theWords) + dayShift
			else -- "Free:"
				set newDays to (item 3 of theWords) - dayShift
			end if
			set item 3 of theWords to newDays
			set item 4 of theWords to singularOrPluralDays(newDays)
			set thisParagraph's contents to theWords as text
		end if
	end repeat
	
	set AppleScript's text item delimiters to linefeed
	set newSummary to theParagraphs as text
	set AppleScript's text item delimiters to astid
	
	tell application "iCal" to set thisEvent's summary to newSummary
end editSummary

on singularOrPluralDays(d)
	if (d is 1) then
		return "day"
	else
		return "days"
	end if
end singularOrPluralDays

on quit
	-- Clear the stored data.
	set originalData to missing value
	continue quit
end quit

Edit: Corrected a goof in the line which restores AppleScript’s text item delimiters. It now actually does that!

Thank you Nigel, this is good!

Rams Free: = total days from when the Rams have been removed from the paddock to the scheduled event date.

The days are being reduced/subtracted if the event is moved into the future (or increased/added if event moved back in time), which isn’t quite right, but that’s easily fixed. :wink:

My script referenced two dates (provided by the farmer) that lie in the note of the event. I prefer this method of checking if the event summary needs to be updated, in case the “stay-open” application happens to not be running and an event (somehow) gets moved.

here is my original script that I’ll modify and merge in your changes. (be kind, it’s not exactly “pretty”)

tell application "iCal" to activate
delay 1.5
tell application "System Events"
	tell process "iCal"
		keystroke "c" using {command down}
		set the_string to the clipboard
	end tell
end tell

-- get current appointment date
set appointment_date to extractBetween(the_string, "Scheduled ", " from") as string
date appointment_date

--get RamsOut/Free Date from note field
set ramsOut to extractBetween(the_string, "Rams Out: ", return & "Misc Notes:") as string
date ramsOut
set ROdiffseconds to ((date appointment_date) - (date ramsOut)) as integer
set ROdiffdays to round (ROdiffseconds / 86400) as string


--get RamsIn/Into Date from note field
set RamsIn to extractBetween(the_string, "Rams In: ", return & "Rams Out:") as string
date RamsIn
set RIdiffseconds to ((date appointment_date) - (date RamsIn)) as integer
set RIdiffdays to round (RIdiffseconds / 86400) as string


-- get event summary from initial clipboard and assign to variables

-- summary format and example is:
--J. Bloggs
--Timbuktu
--Scan for: Single
--Rams Intro: 85 days
--Rams Free: 46 days

set ical_event to paragraphs of the_string
set ical_event_name to item 1 of ical_event
set ical_event_location to item 2 of ical_event
set ical_event_scanFor to item 3 of ical_event
set ical_event_Intro to item 4 of ical_event
set ical_event_Free to item 5 of ical_event

-- update the days, regardless if they've changed or not
set item 4 of ical_event to "Intro: " & RIdiffdays & " days"
set item 5 of ical_event to "Free: " & ROdiffdays & " days"
set ical_event_Intro_updated to (item 4 of ical_event)
set ical_event_Free_updated to (item 5 of ical_event)

--reconstruct the event summary and send it to the system clipboard
set newclipboard to ical_event_name & return & ical_event_location & return & ical_event_scanFor & return & ical_event_Intro_updated & return & ical_event_Free_updated
set the clipboard to newclipboard

-- update Rams In and Out days and paste into/over summary of event.
tell application "System Events"
	tell process "iCal"
		delay 0.25
		keystroke return
		delay 0.25
		keystroke "v" using {command down}
		delay 0.25
		keystroke return
	end tell
end tell



---- The handler ----
to extractBetween(SearchText, startText, endText)
	set tid to AppleScript's text item delimiters -- save them for later.
	set AppleScript's text item delimiters to startText -- find the first one.
	set liste to text items of SearchText
	set AppleScript's text item delimiters to endText -- find the end one.
	set extracts to {}
	repeat with subText in liste
		if subText contains endText then
			copy text item 1 of subText to end of extracts
		end if
	end repeat
	set AppleScript's text item delimiters to tid -- back to original values.
	return extracts
end extractBetween

Example data in an event note is:

Job No: 20101231-113352
Name: Joe Bloggs
Contacts:
“03 1234 1234”,
“03 4321 4321”

Address:
1/23 blah hwy
timbuktu
1234
state

Joining No.: 1
Scan For: Single
Sheep Number: 900
Require Stockman & dogs: false
Rams In: Sunday, 7 November 2010
Rams Out: Thursday, 16 December 2010
Misc Notes: Enter via south gate.

The Rams In: and Rams Out: are the two dates I use to re-calculate the event summary day values.

Thanks again Nigel for your help, I find your method a far better solution.
I’ll stress test it with a couple of hundred events and report back.

Cheers,

Model: intel
AppleScript: 2.1.2?
Browser: Safari 533.19.4
Operating System: Mac OS X (10.6)

mmm,

I think I’m stuck.

I’ve added a comment where I think my edits have failed, which is this line:
set thisEvent to (first event of calendar calendarName whose uid is this UID)

putting in a display dialog command here to debug does not display anything?

my script so far:

property calendarName : "Lambing" -- Your calendar name here.
property idleTime : 5 -- Time (in seconds) between scans. Increase if necessary.

property originalData : missing value

on run
	tell application "iCal"
		activate
		set originalData to {uid, start date, description} of events of calendar calendarName
	end tell
end run

on idle
	-- Get the script's stored UID and start date lists.
	set {eventUIDs, startDates, eventDescription} to originalData
	
	repeat with i from 1 to (count eventUIDs)
		set thisUID to item i of eventUIDs
		set originalStartDate to item i of startDates
		-- get current appoinment date to item i of startDates
		try -- Use a 'try' statement in case this event's been deleted.
			
			tell application "iCal"
				--falling over here? when trying to assign to variable "thisEvent"?
				set thisEvent to (first event of calendar calendarName whose uid is thisUID)
				set currentStartDate to thisEvent's start date
			end tell
			
			--get RamsOut/Free Date from note field
			set ramsOut to extractBetween(eventDescription, "Rams Out: ", return & "Misc Notes:") as string
			date ramsOut
			set ROdiffseconds to ((date currentStartDate) - (date ramsOut)) as integer
			set ROdiffdays to round (ROdiffseconds / 86400) as string
			
			--get RamsIn/Into Date from note field
			set RamsIn to extractBetween(eventDescription, "Rams In: ", return & "Rams Out:") as string
			date RamsIn
			set RIdiffseconds to ((date currentStartDate) - (date RamsIn)) as integer
			set RIdiffdays to round (RIdiffseconds / 86400) as string
			
			-- If the stored and current start dates for this event are on different days, edit the summary.
			if (currentStartDate is not originalStartDate) then
				set currentStartDate's time to 0
				set originalStartDate's time to 0
				set dayShift to (currentStartDate - originalStartDate) div days
				if (dayShift is not 0) then editSummary(thisEvent)
			end if
		end try
	end repeat
	
	-- Refresh the script's stored data.
	tell application "iCal" to set originalData to {uid, start date, description} of events of calendar calendarName
	
	return idleTime
end idle

on editSummary(thisEvent)
	tell application "iCal" to set theSummary to thisEvent's summary
	set theParagraphs to theSummary's paragraphs
	
	set astid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to space
	-- This assumes that the numbers to change are the third words in lines beginning with "Rams".
	repeat with thisParagraph in theParagraphs
		if (thisParagraph begins with "Rams") then
			set theWords to thisParagraph's text items
			if (item 2 of theWords is "Intro") then
				set (item 3 of theWords) to RIdiffdays
			end if
			if (item 2 of theWords is "Free") then
				set (item 3 of theWords) to ROdiffdays
			end if
			set thisParagraph's contents to theWords as text
		end if
	end repeat
	
	set AppleScript's text item delimiters to linefeed
	set newSummary to theParagraphs as text
	set astid to AppleScript's text item delimiters
	
	tell application "iCal" to set thisEvent's summary to newSummary
end editSummary

---- The handler  to extract days from note/description----
on extractBetween(SearchText, startText, endText)
	set tid to AppleScript's text item delimiters -- save them for later.
	set AppleScript's text item delimiters to startText -- find the first one.
	set liste to text items of SearchText
	set AppleScript's text item delimiters to endText -- find the end one.
	set extracts to {}
	repeat with subText in liste
		if subText contains endText then
			copy text item 1 of subText to end of extracts
		end if
	end repeat
	set AppleScript's text item delimiters to tid -- back to original values.
	return extracts
end extractBetween


on quit
	-- Clear the stored data.
	set originalData to missing value
	continue quit
end quit

any suggestions as to where I’ve gone wrong?

Cheers,

fixed it…

didn’t realise I was acting on all event descriptions rather than just the " i’s " description.

property calendarName : "Lambing" -- Your calendar name here.
property idleTime : 5 -- Time (in seconds) between scans. Increase if necessary.

property originalData : missing value

on run
	tell application "iCal"
		activate
		set originalData to {uid, start date, description} of events of calendar calendarName
	end tell
end run

on idle
	-- Get the script's stored UID and start date lists.
	set {eventUIDs, startDates, eventDescriptions} to originalData
	repeat with i from 1 to (count eventUIDs)
		set thisUID to item i of eventUIDs
		set originalStartDate to item i of startDates
		-- get current appoinment date to item i of startDates
		try -- Use a 'try' statement in case this event's been deleted.
			tell application "iCal"
				set thisEvent to (first event of calendar calendarName whose uid is thisUID)
				set currentStartDate to thisEvent's start date
				set eventDescription to thisEvent's description
			end tell
			
			--Determine Rams Out/Free days here 
			set ramsOut to extractBetween(eventDescription, "Rams Out: ", return & "Misc Notes:") as string
			set ramsOut to date ramsOut
			set ROdiffseconds to (currentStartDate) - (ramsOut) as integer
			set ROdiffdays to round (ROdiffseconds / 86400) --as string
			
			--Determin Rams In/Into days here			
			set ramsIn to extractBetween(eventDescription, "Rams In: ", return & "Rams Out:") as string
			set ramsIn to date ramsIn
			set RIdiffseconds to (currentStartDate) - (ramsIn) as integer
			set RIdiffdays to round (RIdiffseconds / 86400)
			
			-- now loop through all events and update days if needed.
			editSummary(thisEvent, ROdiffdays, RIdiffdays)
		end try
	end repeat
	
	-- Refresh the script's stored data.
	tell application "iCal" to set originalData to {uid, start date, description} of events of calendar calendarName
	return idleTime
end idle

on editSummary(thisEvent, ROdiffdays, RIdiffdays)
	tell application "iCal" to set theSummary to thisEvent's summary
	set theParagraphs to theSummary's paragraphs
	
	set astid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to space
	
	-- This assumes that the numbers to change are the second words in lines beginning with "Intro" or "Free".
	repeat with thisParagraph in theParagraphs
		if (thisParagraph begins with "Intro") then
			set theWords to thisParagraph's text items
			set (item 2 of theWords) to RIdiffdays
			set thisParagraph's contents to theWords as text
		end if
		if (thisParagraph begins with "Free") then
			set theWords to thisParagraph's text items
			set (item 2 of theWords) to ROdiffdays
			set thisParagraph's contents to theWords as text
		end if
	end repeat
	
	set AppleScript's text item delimiters to linefeed
	set newSummary to theParagraphs as text
	set AppleScript's text item delimiters to astid
	tell application "iCal" to set thisEvent's summary to newSummary
end editSummary

---- The handler  to extract days from note/description----
on extractBetween(SearchText, startText, endText)
	set tid to AppleScript's text item delimiters -- save them for later.
	set AppleScript's text item delimiters to startText -- find the first one.
	set liste to text items of SearchText
	set AppleScript's text item delimiters to endText -- find the end one.
	set extracts to {}
	repeat with subText in liste
		if subText contains endText then
			copy text item 1 of subText to end of extracts
		end if
	end repeat
	set AppleScript's text item delimiters to tid -- back to original values.
	return extracts
end extractBetween


on quit
	-- Clear the stored data.
	set originalData to missing value
	continue quit
end quit

now to add a means to exclude calendars, unless they start with “Lamb” etc etc

thanx again

I’m having difficulty trying to filter calendars with my script posted here.

Because I’ve never used “on idle” I’m not sure how to structure the repeat to filter out unwanted calendars.

All I’m wanting to do is to traverse events of calendars that have a name starting with “Lambing” for example.

I’ve looked at the code at this post: http://www.macscripter.net/viewtopic.php?id=31833 but am getting confused how/where to merge a repeat into the code I’ve already got.

Can someone please provide some pseudocode that uses the existing code but included a means to filter out unwanted calendars?

Tah

Here are the on run and on idle handlers that I’ve attempted to add the calendar filtering to…

on run
	set current_date to current date
	tell application "iCal"
		set all_calendars to every calendar
	end tell
end run

on idle
	-- Get the script's stored UID and start date lists.
	tell application "iCal"
		repeat with current_calendar in all_calendars
			set originalData to {uid, start date, description} of events of calendar current_calendar
			repeat with current_calendar in all_calendars
				if (name of current_calendar) starts with "Lambing" then
					set {eventUIDs, startDates, eventDescriptions} to originalData
					repeat with i from 1 to (count eventUIDs)
						set thisUID to item i of eventUIDs
						set originalStartDate to item i of startDates
						-- get current appoinment date to item i of startDates
						try -- Use a 'try' statement in case this event's been deleted.
							tell application "iCal"
								set thisEvent to (first event of calendar current_calendar whose uid is thisUID)
								set currentStartDate to thisEvent's start date
								set eventDescription to thisEvent's description
							end tell
							
							--Determine Rams Out/Free days here 
							set ramsOut to extractBetween(eventDescription, "Rams Out: ", return & "Misc Notes:") as string
							set ramsOut to date ramsOut
							set ROdiffseconds to (currentStartDate) - (ramsOut) as integer
							set ROdiffdays to round (ROdiffseconds / 86400) --as string
							
							--Determin Rams In/Into days here			
							set RamsIn to extractBetween(eventDescription, "Rams In: ", return & "Rams Out:") as string
							set RamsIn to date RamsIn
							set RIdiffseconds to (currentStartDate) - (RamsIn) as integer
							set RIdiffdays to round (RIdiffseconds / 86400)
							
							-- loop through all events and update days.
							editSummary(thisEvent, ROdiffdays, RIdiffdays)
						end try
					end repeat
					-- Refresh the script's stored data.
					tell application "iCal" to set originalData to {uid, start date, description} of events of calendar current_calendar
					return idleTime
				end if
			end repeat
		end repeat
	end tell
end idle

but upon launching the application I get:


am quite stuck now…

Hi, tanglez.

You seem to be living up to your name. :wink:

  1. The cause of your immediate error was that you had the word ‘calendar’ in front of a variable which already contained a calendar reference.

  2. If you’re not watching out for the events’ start dates having changed since last time, there’s no need to store the original data.

  3. An ‘idle’ handler in a stay-open applet is called periodically by the system, the interval between calls being determined by the last result returned by the handler. So the last thing the handler has to do before it finishes is to return how many seconds it wants to wait before it’s called again.

  4. If you’re calling a handler from within a ‘tell’ statement, you have to put ‘my’ in front of the call so that the ‘told’ thing doesn’t think it’s supposed to understand it.

I’ve done a version of the script based on your “fixed” version in post #6, but, since I don’t have calendars filled with your events, I haven’t been able to test it as a complete entity:

property idleTime : 5 -- Time (in seconds) between scans. Increase if necessary.

on run
	tell application "iCal" to activate
end run

on idle
	tell application "iCal"
		set theCalendars to calendars whose name begins with "Lambing"
		
		repeat with i from 1 to (count theCalendars)
			set thisCalendar to item i of theCalendars
			set theseEvents to thisCalendar's events
			repeat with j from 1 to (count theseEvents)
				set thisEvent to item j of theseEvents
				set currentStartDate to thisEvent's start date
				set eventDescription to thisEvent's description
				
				--Determine Rams Out/Free days here 
				set ramsOut to my entryFor(eventDescription, "Rams Out: ")
				set ROdiffdays to (currentStartDate - (my date ramsOut)) div days -- 'date ramsOut' only works if the computer's date preferences match the format used in the text.
				
				--Determine Rams In/Into days here			
				set ramsIn to my entryFor(eventDescription, "Rams In: ")
				set RIdiffdays to (currentStartDate - (my date ramsIn)) div days -- Ditto 'date ramsin'.
				
				-- Update days if needed.
				my editSummary(thisEvent, ROdiffdays, RIdiffdays)
			end repeat
		end repeat
	end tell
	
	return idleTime -- Tell the system to call this idle handler again in this many seconds' time.
end idle

on editSummary(thisEvent, ROdiffdays, RIdiffdays)
	tell application "iCal" to set theSummary to thisEvent's summary
	set theParagraphs to theSummary's paragraphs
	
	set astid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to space
	
	-- This assumes that the numbers to change are the second words in lines beginning with "Intro" or "Free".
	repeat with thisParagraph in theParagraphs
		if (thisParagraph begins with "Intro") then
			set theWords to thisParagraph's text items
			set (item 2 of theWords) to RIdiffdays
			set thisParagraph's contents to theWords as text
		end if
		if (thisParagraph begins with "Free") then
			set theWords to thisParagraph's text items
			set (item 2 of theWords) to ROdiffdays
			set thisParagraph's contents to theWords as text
		end if
	end repeat
	
	set AppleScript's text item delimiters to linefeed
	set newSummary to theParagraphs as text
	set AppleScript's text item delimiters to astid
	if (newSummary is not theSummary) then tell application "iCal" to set thisEvent's summary to newSummary
end editSummary

--- The handler  to extract days from note/description----
on entryFor(SearchText, header)
	set tid to AppleScript's text item delimiters -- save them for later.
	set AppleScript's text item delimiters to header
	set extract to paragraph 1 of text item 2 of SearchText
	set AppleScript's text item delimiters to tid -- back to original values.
	
	return extract
end entryFor

on quit
	-- Clear the stored data.
	set originalData to missing value
	continue quit
end quit

LOL, yes… my username does suggest I’m in a pickle…

I tried your changes and keep getting an error of:

"Can’t make date “Thursday, 16 December 2010” of application “iCal” into type number or date. "

where the date above is the “Rams Out:” date within the line in the notes of my test event.

With respect to your comment about whether the script will work subject to the computer’s date preferences matching, I tested this with:

set thedate to current date

and got an applescript result of:

date "Wednesday, 12 January 2011 12:58:30 PM"

Also played with:

set ramsOut to "Thursday, 16 December 2010"

and got a result of:

"Thursday, 16 December 2010"

and finally:

set ramsOut to "Thursday, 16 December 2010"
set ramsOut to date ramsOut

returns a result of:

date "Thursday, 16 December 2010 12:00:00 AM"

In desperation, I even appended a timestamp onto the date string in the ical test event to no avail, so I’m confident the issue lies outside of evaluating the Rams In/Out strings, particularly given that my old code/effort works successfully, I don’t this is the cause of the error.

Consequently, I endeavoured to use some of my old (ugly) cold along with your new code and still encountered the same error.

As I was clearly “tangled” before, needless to say I’m even more lost now, as I saw similar error message postings (http://macscripter.net/viewtopic.php?id=30291) relating to iCal bugs? although they are somewhat old now…

Thanks again for your efforts. I just wish I had your knowledge so I wouldn’t have to constantly pester…

Cheers,

using the code below to dump out currentStartDate or eventDescription:

-------------
				set the_file to ((path to desktop as text) & "test.txt")
				set the_data to currentStartDate -- or eventDescription
				try
					set dataStream to open for access file the_file with write permission
					set eof of dataStream to 0
					write the_data to dataStream starting at eof as list
					close access dataStream
				on error
					try
						close access file the_file
					end try
				end try
				set read_data to (read file the_file as list) as text
				-------------

I’m getting something inside the test.txt file that is not asci… (binary?)

would this be the cause of the problem, i.e. “can’t make date” ??

I’ve been using “display dialog” to debug and show me variables at various stages, but even this is failing which is why I resorted to the above of writing the variable to file.

I see applescript has a “log” command, but it seems dead too… anyone know how to use it. (tried

tell application "Finder" to log currentStartDate -- or eventDescription

but didn’t have much fun here either…

Cheers,

Ah, yes. I remember now. There’s an “issue” with using a <‘date’ + string variable> date specifier within an iCal tell statement. Some sort of terminology clash. One cure for that is to place the word ‘my’ in front of the specifier to ensure that iCal doesn’t try to resolve it but leaves it to AppleScript. I’ve changed it in the script above.

The note about the computer preferences only applies to the language used and the preferred order of day, month, and year. You’re unlikely to be affected by it yourself, but I thought it should be pointed out.

ah…

No wonder I wasn’t getting anywhere with my efforts.

I guess that’s why my old original code was so “ugly”…

Never mind, I’m very appreciative of your help Nigel, NO WAY I would’ve solved this one on my own.

Thanx again,

R.