Just because you got an error doesn't mean Applescript won't run under 10.8.2, it just means your programming is incorrect.
property month_names : {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
property setname : "Daily Data " & (current date)
property SERVICEFOLDER : "Data Folder"
property DataStart : ""
property DataEnd : ""
property StartFlag : 0
property endFlag : 0
property DailyTallies : {}
property DailyAverager : {}
global TallyName
global DataYear
global GraphDate
global TheSheetName
on run
my SetUp()
end run
on SetUp()
tell application "Numbers"
if not (exists document 1) then
set myNewDoc to my makeNewDoc(setname & ".numbers", path to documents folder as text)
end if
if not (exists document 1) then error number -128
if "untitled" is in name of document 1 then
set name of document 1 to setname
end if
end tell
set PathToDesktop to path to desktop as Unicode text
set MailPrintingFolder to PathToDesktop & SERVICEFOLDER
set the DataYear to ""
set StartFlag to 0
tell application "Finder"
set tempstring to "United Widgets." & return & return
repeat
display dialog tempstring & "Enter the year you wish to display DAILY AVERAGE breakdown Data for..." default answer the DataYear buttons {"Cancel", "Enter"} default button 2
copy the result as list to {the DataYear, the button_pressed}
set TallyName to (MailPrintingFolder & ":.Detailed Yearly Tally " & DataYear) as text
if exists TallyName then
my EnterStart()
exit repeat
else
beep
set tempstring to "United Widgets." & return & return & "There is no file for year " & DataYear & "." & return & return
end if
end repeat
end tell
end SetUp
on EnterStart()
tell application "Finder"
set tempstring to ""
repeat
display dialog tempstring & "Enter the Month for " & DataYear & " you wish to start getting Mail Manager Data for..." default answer the DataStart buttons {"Cancel", "Enter"} default button 2
copy the result as list to {the DataStart, the button_pressed}
if my MonthNameCheck(DataStart) then
my EnterEnd()
exit repeat
else
set tempstring to "That entry was not correct." & return & return
end if
end repeat
end tell
end EnterStart
on EnterEnd()
tell application "Finder"
set tempstring to ""
repeat
display dialog tempstring & "Starting month = " & DataStart & " " & DataYear & return & return & "Enter the Month for " & DataYear & " you wish to finish getting Mail Manager Data for..." default answer the DataEnd buttons {"Cancel", "Go Back", "Enter"} default button 3
copy the result as list to {the DataEnd, the button_pressed}
if button_pressed = "Go Back" then my EnterStart()
if my MonthNameCheck(DataEnd) then
my CheckMonthOrder()
my MakeMonths()
exit repeat
else
set tempstring to "That entry was not correct." & return & return
end if
end repeat
end tell
end EnterEnd
on MakeMonths()
repeat with x from 1 to 7 * 12
set end of DailyTallies to 0
set end of DailyAverager to 0
end repeat
tell application "Numbers"
activate
if not (exists document 1) then
display dialog "There is no document open." buttons {"Cancel", "OK"} default button 2
my SetUp()
end if
set TheSheetName to "DAILY DATA " & DataEnd & " " & DataStart & " " & DataYear
tell document 1
tell sheet 1
set this_table to make new table with properties {name:TheSheetName, column count:8, row count:endFlag - StartFlag + 2}
tell table TheSheetName
-- set any global cell properties
set the height of every row to 24
set the width of columns 2 thru 8 to 60
set the vertical alignment of every row to center
set the alignment of every row to center
tell column 1
-- set specific properties for the title column
set the vertical alignment to center
set the alignment to center
-- insert labels
set value of cell (1) to DataYear
repeat with i from 2 to endFlag - StartFlag + 2
set value of cell i to item (StartFlag + i - 2) of the month_names
end repeat
end tell
tell row 1
-- set specific properties for the title row
set the vertical alignment to center
set the alignment to center
-- insert labels
repeat with x from 1 to 7
set value of (cell (x + 1)) to (item x of {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"})
end repeat
end tell
end tell
end tell
end tell
end tell
my GraphIt()
end MakeMonths
on GraphIt()
set WholeList to my ReadFile(TallyName)
set MonthlyString to {}
repeat with TheDailyCycle from 1 to count of WholeList by 52
set thetempmonth to item TheDailyCycle of WholeList
copy ((offset of ((characters 1 thru 3 of thetempmonth) as text) in "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") + 3) / 4 as integer to themonthOffSet -- set 1 to 12
if themonthOffSet ≥ StartFlag and themonthOffSet ≤ endFlag then
set end of MonthlyString to ((thetempmonth) as text)
set thetempday to item (TheDailyCycle + 1) of WholeList
set TestDate to date (thetempday & "/" & thetempmonth & "/" & DataYear)
set theweekday to weekday of TestDate as text --set Sunday to Saturday
copy ((offset of ((characters 1 thru 3 of theweekday) as text) in "sun mon tue wed thu fri sat") + 3) / 4 as integer to theDayOffSet -- set 1 to 7
set end of MonthlyString to ((characters 1 thru 3 of theweekday) as text)
set end of MonthlyString to thetempday
set tallysum to 0
repeat with TallyCounter from 3 to 49 by 2 -- Go through the 24 hours for each day
set ActualHourCount to (item (TheDailyCycle + TallyCounter) of WholeList)
set tallysum to tallysum + ActualHourCount
end repeat
set dayoffset to ((themonthOffSet * 7) - 7 + theDayOffSet)
set item dayoffset of DailyTallies to (item dayoffset of DailyTallies) + tallysum
set item dayoffset of DailyAverager to (item dayoffset of DailyAverager) + 1
end if
end repeat
repeat with x from StartFlag to endFlag
tell application "Numbers"
tell document 1
tell sheet 1
tell table TheSheetName
tell (row (x - StartFlag + 2))
repeat with z from 1 to 7
set tempvalue to (item (((x * 7) - 7) + z) of DailyAverager)
if tempvalue > 0 then set value of cell (z + 1) to (item (((x * 7) - 7) + z) of DailyTallies) / tempvalue as integer
end repeat
end tell
end tell
end tell
end tell
end tell
end repeat
end GraphIt
on makeNewDoc(n, d)
tell application "Numbers" to activate
tell application "System Events" to tell (first process whose title is "Numbers") to tell menu bar 1 to tell menu bar item 3 to tell menu 1 to click menu item 1
(* menu bar item 3 for menu File *)
(* menu item 1 for New *)
try
tell application "Numbers" to save document 1 in file (d & n)
return (d & n) as alias
on error
tell application "Finder"
activate
display dialog "Please choose a Template to add the Mail Manager Data to, then re-run this Application."
end tell
end try
end makeNewDoc
on CheckMonthOrder()
if StartFlag > endFlag then
set temp1 to StartFlag
set temp2 to DataStart
set StartFlag to endFlag
set DataStart to DataEnd
set endFlag to temp1
set DataEnd to temp2
end if
end CheckMonthOrder
on MonthNameCheck(testMonth)
set theMonths to {}
set theMonths to {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} as list
set ExitFlag to false
repeat with x from 1 to count of theMonths
if testMonth is in item x of theMonths then
if StartFlag = 0 then
set DataStart to item x of theMonths
set StartFlag to x
set ExitFlag to true
exit repeat
else
set DataEnd to item x of theMonths
set endFlag to x
set ExitFlag to true
exit repeat
end if
end if
end repeat
return ExitFlag
end MonthNameCheck
on ReadFile(TheFileName)
try
set WholeList to (read file (TheFileName) using delimiter ",")
return WholeList
on error
return {}
end try
end ReadFile