Help! My script not backwards compatible.

A year or so ago I had someone help me write a script that I use for creating monthly folders for filing things at work. Now a coworker would like to use the script but he keeps getting an error “Can’t make “4” into expected type” I think the cause is this line:

set m to item (1st word of chosenMonth as integer) of theMonths

I am using AS 1.10.7 on OSX 10.4.11 and he is using AS 1.9.3 on OSX 10.3.9. can someone take a look at the script and tell me what might be wrong.

property theMonths : {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}
property theWeekdays : {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}

set destinationFolder to choose folder with prompt "Choose destination folder"
tell (current date) to set thisMonth to (it - (its day) * days + days - (its time))
set monthList to {}
repeat with i from 1 to 12
	tell (thisMonth + i * 32 * days) to set end of monthList to ((its month as integer) as string) & " / " & its year
end repeat
set chosenMonth to (choose from list monthList with prompt "choose a month") as string
if chosenMonth is "false" then return
tell thisMonth to set {its month, year} to words of chosenMonth
tell thisMonth to tell it + 32 * days to set lastDate to day of (it - (its day) * days + 86399)
set m to item (1st word of chosenMonth as integer) of theMonths

repeat with oneDay from 0 to lastDate - 1
	tell (thisMonth + oneDay * days) to set {wk, dy} to {its weekday as integer, its day}
	if wk > 2 then
		set folderName to text -2 thru -1 of ("0" & dy) & space & m & space & item wk of theWeekdays
		try
			tell application "Finder" to make new folder at destinationFolder with properties {name:folderName}
		end try
	end if
end repeat

Hi,

in Panther it’s not possible to set the month property of a date by an integer.
This might be a workaround


property theMonths : {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}
property theWeekdays : {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}
property monthsConstants : {January, February, March, April, May, June, July, August, September, October, November, December}
.



.
if chosenMonth is "false" then return
set {mn, yr} to words of chosenMonth
tell thisMonth
	set its month to item (mn as integer) of monthsConstants
	set year to yr
end tell
tell thisMonth to tell it + 32 * days to set lastDate to day of (it - (its day) * days + 86399)
set m to item (mn as integer) of theMonths
.

Now i get an error “can’t set ‘day’ as integer”. I am sure it a similar problem but I have no idea how to correct the issue. Do I need a constant of day names? and how do I apply that to what I already have?

this should do it

property monthsConstants : {January, February, March, April, May, June, July, August, September, October, November, December}

set destinationFolder to choose folder with prompt "Choose destination folder"
tell (current date) to set thisMonth to (it - (its day) * days + days - (its time))
set monthList to {}
repeat with i from 1 to 12
	tell (thisMonth + i * 32 * days) to set end of monthList to ((its month as integer) as string) & " / " & its year
end repeat
set chosenMonth to (choose from list monthList with prompt "choose a month") as string
if chosenMonth is "false" then return
set {mn, yr} to words of chosenMonth
tell thisMonth
	set its month to item (mn as integer) of monthsConstants
	set year to yr
end tell
tell thisMonth to tell it + 32 * days to set lastDate to day of (it - (its day) * days + 86399)
set m to capitalize(text 1 thru 3 of (item (mn as integer) of monthsConstants as string))
repeat with oneDay from 0 to lastDate - 1
	tell (thisMonth + oneDay * days) to set {wk, dy} to {its weekday, its day}
	if wk is not Sunday and wk is not Monday then
		set folderName to text -2 thru -1 of ("0" & dy) & space & m & space & capitalize(text 1 thru 3 of (wk as string))
		try
			tell application "Finder" to make new folder at destinationFolder with properties {name:folderName}
		end try
	end if
end repeat

on capitalize(s)
	return (do shell script "echo -n " & s & " | tr a-z A-Z")
end capitalize