I’ve found this site immensely helpful for learning AppleScript and solving issues that others have run into, but I can’t seem to find anyone else running into this kind of issue. Maybe because I’m not entirely sure what the issue is.
The basic issues I’m running into is when I try to do something like this:
copy lib's CalendarDate to firstDate
What happens when I run, I get an error message that reads “error “Can’t make CalendarDate into type reference.” number -1700 from CalendarDate to reference”
I feel I should mention that I’m running Mac OS X 10.8.4, but I’ve also tested this on Mac OS X 10.7.5 with the same results.
So, here’s how we get to the issue: I was following this article about Test Driven Development with AppleScript: http://www.mactech.com/articles/mactech/Vol.24/24.04/Test-DrivenDevelopmentUsingAppleScript/index.html
The issue started when I took the CalendarDate script and put it into its own script file. Now when I try to initialize the CalendarDate “object”, well, I guess it doesn’t know how to do that from a different file.
Here’s the two script files I’m dealing with. Please Note that you need the ASUnit script from this site and put it into your /Users/[your username]/Library/Scripts folder: http://nirs.freeshell.org/asunit/
I’ve got my Date.scpt file (located on my Desktop) which looks like this:
script |CalendarDate|
-- CalendarDate has three properties - day, month, and year.
property calendarDay : 0.0
property calendarMonth : 0.0
property calendarYear : 0.0
-- Sets the calendarDay property to the value passed to it.
on SetDay(theDay)
set calendarDay to theDay
end SetDay
-- Sets the calendarMonth property to the value passed to it.
on SetMonth(theMonth)
set calendarMonth to theMonth
end SetMonth
-- Sets the calendarYear property to the value passed to it.
on SetYear(theYear)
set calendarYear to theYear
end SetYear
-- Returns the value of the calendarDay property.
on GetDay()
return calendarDay
end GetDay
-- Returns the value of the calendarMonth property.
on GetMonth()
return calendarMonth
end GetMonth
-- Returns the value of the calendarYear property.
on GetYear()
return calendarYear
end GetYear
on InitializeDate(myDate, myMonth, myYear)
SetDay(myDate)
SetMonth(myMonth)
SetYear(myYear)
end InitializeDate
end script
And my DateTest.scrpt (also located on my Desktop), which is the file that you run, which produces the error:
property parent : load script file ((path to scripts folder from user domain as string) & "ASUnit.scpt")
property lib : load script file ((path to desktop as string) & "Date.scpt")
property suite : makeTestSuite("My Date Tests")
script |DateTests|
property parent : registerFixture(me)
property firstDate : missing value
property secondDate : missing value
on setUp()
copy lib's CalendarDate to firstDate
copy lib's CalendarDate to secondDate
-- Set the values for the first date.
tell firstDate to InitializeDate(21, 9, 2007)
-- Set the values for the second date.
tell secondDate to InitializeDate(25, 9, 2005)
end setUp
script |CheckSameMonth|
property parent : registerTestCase(me)
set p to firstDate's GetMonth()
set d to secondDate's GetMonth()
should(p is equal to d, "month not equal!")
end script
script |CheckDifferentMonth|
property parent : registerTestCase(me)
set p to firstDate's GetMonth()
set d to secondDate's GetMonth()
should(p is not equal to d, "month is the same!")
end script
script |CheckSameDay|
property parent : registerTestCase(me)
set p to firstDate's GetDay()
set d to secondDate's GetDay()
should(p is equal to d, "day not equal!")
end script
script |CheckDifferentDay|
property parent : registerTestCase(me)
set p to firstDate's GetDay()
set d to secondDate's GetDay()
should(p is not equal to d, "day is the same!")
end script
script |CheckSameYear|
property parent : registerTestCase(me)
set p to firstDate's GetYear()
set d to secondDate's GetYear()
should(p is equal to d, "year not equal!")
end script
script |CheckDifferentYear|
property parent : registerTestCase(me)
set p to firstDate's GetYear()
set d to secondDate's GetYear()
should(p is not equal to d, "year is the same!")
end script
end script
run makeTextTestRunner(suite)
Thank you so much for your time.
Model: iMac
AppleScript: 2.5.1
Browser: Safari 536.30.1
Operating System: Mac OS X (10.8)