This is probably the last hurdle for my app.
I've got a table that has to contain a fixed set of data, so I can't use an Array Controller.
on SetUpSessionDisplayData()
set pathToDataFolder to path to documents folder as text
tell application "Finder"
try
set checkFolder to pathToDataFolder & "ADJ Documents" as text
set everyFileToCheck to name of (every file of folder checkFolder whose (name starts with ("ADJ " as text)))
set SessionDataInitial to {}
repeat with eachFile in everyFileToCheck
set workingFilePath to POSIX path of (pathToDataFolder & "ADJ Documents:" & eachFile as text)
try
set nowReadList to current application's NSDictionary's dictionaryWithContentsOfFile_(workingFilePath)
set allTheSettings to nowReadList's NSDatesSavingData
set checkStartDateTimeNSDate to allTheSettings's startDateTimeNSDateData
set checkFinishDateTimeNSDate to allTheSettings's finishDateTimeNSDateData
set displayASStartTime to ((extras's fordNSDateToASDate_(checkStartDateTimeNSDate)) as date) as text
set displayAsFinishTime to ((extras's fordNSDateToASDate_(checkFinishDateTimeNSDate)) as date) as text
set eachSessionEntry to {}
set end of eachSessionEntry to eachFile
set end of eachSessionEntry to displayASStartTime
set end of eachSessionEntry to displayAsFinishTime
set end of SessionDataInitial to eachSessionEntry
end try
end repeat
set SessionsInOrderArray to {}
set theTotalCount to count of SessionDataInitial
repeat
set lowestFlag to 1
repeat with eachSession from 1 to count of SessionDataInitial
set checkSession to item eachSession of SessionDataInitial
if checkSession ≠ "" then
try
set checkStart to checkSession's NSDateStart
if eachSession as integer = 1 then
set compareStartDate to checkStart
else
if checkStart's compare_(compareStartDate) < 0 then
set lowestFlag to eachSession as integer
set compareStartDate to checkStart
end if
end if
end try
end if
end repeat
set end of SessionsInOrderArray to item lowestFlag of SessionDataInitial
if (count of SessionsInOrderArray) as integer ≥ theTotalCount as integer then exit repeat
set removeItemList to {}
repeat with x from 1 to count of SessionDataInitial
if x ≠ lowestFlag then set end of removeItemList to item x of SessionDataInitial
end repeat
set SessionDataInitial to removeItemList
end repeat
set x to 1
repeat with eachItem in SessionsInOrderArray
say 1
tell my displaySessionsTable to tableView_setObjectValue_forTableColumn_row_({my displaySessionsTable}, {item 1 of eachItem as text}, {"sessionsName"}, {x as integer})
set x to x + 1
say 2
end repeat
on error errmsg
display dialog "SetUpSessionDisplayData " & errmsg
end try
end tell
end SetUpSessionDisplayData