I’m adding a class like Shane’s AppleScriptObjC Explored book shows for the Ad Table.
When I left work yesterday I thought everything was good but this morning I noticed that the property dateStamp was being added as yesterday’s date and not getting the current date. I’m guessing that it is keeping whatever it is at compile time. I have added a handler called setCurrentDateStamp_ (commented out below) called from applicationWillFinishLaunching_ in my app delegate and I can see it gets called to set dateStamp property but when I add a new item to my table it will have missing value since that is what I compiled it with. How can I get my property to always get the current date?
script AdLog
property parent : class "NSObject"
property insigniaName : missing value
property artistName : missing value
property processName : missing value
property timeStamp : missing value
property dateStamp : missing Value --(short date string of (current date))
property monthStamp : (month of (current date) as string)
property yearStamp : (year of (current date) as string)
-- on setCurrentDateStamp_(sender)
-- set my dateStamp to ((short date string of (current date)))
-- tell me to log dateStamp
-- end setCurrentDateStamp_
on setInsigniaName_(newVal)
if newVal = missing value then set newVal to "Missing Value"
set my insigniaName to newVal
end setInsigniaName_
on setArtistName_(newVal)
if newVal = missing value then set newVal to "Missing Value"
set my artistName to newVal
end setArtistName_
on setProcessName_(newVal)
if newVal = missing value then set newVal to "Missing Value"
set my processName to newVal
end setProcessName_
on setTimeStamp_(newVal)
if newVal = missing value then set newVal to "Missing Value"
set my timeStamp to newVal
end setTimeStamp_
on setDateStamp_(newVal)
if newVal = missing value then set newVal to "Missing Value"
set my dateStamp to newVal
end setDateStamp_
on setMonthStamp_(newVal)
if newVal = missing value then set newVal to "Missing Value"
set my monthStamp to newVal
end setMonthStamp_
on setYearStamp_(newVal)
if newVal = missing value then set newVal to "Missing Value"
set my yearStamp to newVal
end setYearStamp_
on logsAsTabbedText()
return (insigniaName as text) & tab & (artistName as text) & tab & (processName as text) & tab & (timeStamp as text) & tab & (dateStamp as text) & tab & (monthStamp as text) & tab & (yearStamp as text)
end adAsTabbedText
on specFromTabbedText_(tabbedText)
set theValues to (tabbedText's componentsSeparatedByString_(tab)) as list
if length of theValues = 7 then
setInsigniaName_(item 1 of theValues)
setArtistName_(item 2 of theValues)
setProcessName_(item 3 of theValues)
setTimeStamp_(item 4 of theValues)
setDateStamp_(item 5 of theValues)
setMonthStamp_(item 6 of theValues)
setYearStamp_(item 7 of theValues)
else
setInsigniaName_("Invalid entry")
end if
end specFromTabbedText_
end script