Help with a Scripting issue

Hello-
I am new to AppleScript and apologize if I posted this in the wrong place. I looked for the “Scripted applications” section and found an FAQ. I have an issue with a script that was written for InDesign CS2. It was written to make a printable version of the notes in a document for proofing. It creates note “markers” (colored squares with a number in them) for each note in the document and makes a separate document and pastes each note marker number and note into it. It will not work in InDesign CS4 and I get the “Error: This version of InDesign is unknown!” message. If anyone can tell me why it will not work I would be most appreciative.
Thanks,
Curt
here is the script:

tell application "Adobe InDesign CS4"
	set idVersion to first character of (version as string)
	
	tell active document
		--Basal character style name changed in ID4
		if idVersion = "3" then
			set tagCharStyleName to "[No character style]"
			set tagParaStyleName to "[No paragraph style]"
		else if idVersion = "4" then
			set tagCharStyleName to "[None]"
			set tagParaStyleName to "[Basic Paragraph]"
		else
			display dialog "Error: This version of InDesign is unknown!" buttons "Cancel" default button 1
		end if
		
		--These are the layers, styles, & sizes we'll need
		set tagLayerName to "Image IDs" --layer name
		set tagParaStyleName to "K4 note number" --paragraph stylesheet
		set tagBoxColor to "Image ID tag" --swatch color, THIS SHOULD BE A SPOT COLOR FOR SAFETY
		set tagBoxStrokeColor to "Black" --swatch stroke color
		set tagBoxStrokeWeight to ".5" --pts
		set tagLabel to "editor note tag" --scripting label for the box
		set boxWidth to "10.0" --picas, default box width
		set boxHeight to "2.0" --picas, default box height
		set defaultValue to "Image ID to come" --the default text to put in the box
		set textWidth to (5.5 / 12) --picas, the amount of space the average character takes up
		set textPadding to "1.0" --picas, the amount of padding at each end
		set vertJust to center align --vertical justification of the text in the box
		
		--Check for existence of layers, styles, & swatches above
		considering case
			if name of every layer does not contain tagLayerName then
				if name of every layer contains "Image ID#" then
					set name of layer "Image ID#" to tagLayerName
				else
					display dialog "Need layer \"" & tagLayerName & "\" to continue." buttons {"Cancel"} default button 1
				end if
			else
				set tagLayer to layer tagLayerName
			end if
			
			if name of every character style does not contain tagCharStyleName then
				display dialog "Need character style \"" & tagCharStyleName & "\" to continue." buttons {"Cancel"} default button 1
			else
				set tagCharStyle to character style tagCharStyleName
			end if
			
			if name of every color does not contain tagBoxColor then
				set makeColor to display dialog "Need color swatch \"" & tagBoxColor & "\" to continue. Okay to create it?" buttons {"Cancel", "OK"} default button 2
				if button returned of makeColor = "OK" then
					try
						set imageTagColor to make color with properties {model:spot, space:CMYK, color value:{0, 20, 100, 0}, name:"Image ID tag"}
					on error
						display dialog "Failed to create color swatch \"" & tagBoxColor & "\"." buttons {"Cancel"} default button 1
					end try
				else
					display dialog "Cannot continue without color swatch \"" & tagBoxColor & "\"." buttons {"Cancel"} default button 1
				end if
			else
				if model of color tagBoxColor ≠ spot then
					display dialog "Color swatch \"" & tagBoxColor & "\" to must be a spot color to continue." buttons {"Cancel"} default button 1
				end if
			end if
			
			if name of every paragraph style does not contain tagParaStyleName then
				set titleFont to "Lucida Grande"
				set titleStyle to "Regular"
				set titleSize to "12" --pt
				set titleLead to "12" --pt
				set titleColor to color "Black"
				set titleAlign to center align
				set makePara to display dialog "Need paragraph style \"" & tagParaStyleName & "\" to continue. Okay to create it?" buttons {"Cancel", "OK"} default button 2
				if button returned of makePara = "OK" then
					try
						set newParaStyle to make paragraph style with properties {applied font:titleFont, point size:titleSize, leading:titleLead, fill color:titleColor, justification:titleAlign, name:tagParaStyleName}
					on error
						display dialog "Failed to create paragraph style \"" & tagParaStyleName & "\"." buttons {"Cancel"} default button 1
					end try
					set tagParaStyle to paragraph style tagParaStyleName
				else
					display dialog "Need paragraph style \"" & tagParaStyle & "\" to continue." buttons {"Cancel"} default button 1
				end if
			else
				set tagParaStyle to paragraph style tagParaStyleName
			end if
		end considering
		
		--Create an empty report
		set theReport to {"" & name, "----------------------"}
		
		--Get all the notes
		set myNotes to every note of every story
		set noteCounter to 1
		
		repeat with thisNote in myNotes
			--Get the properites of thisNote
			set thisOffset to story offset of thisNote
			if thisOffset = 0 then
				set thisOffset to 1
			end if
			set thisStory to parent of thisNote
			
			--Put the insertion pointer at thisNote and get the y,x of it
			try
				select insertion point thisOffset of thisStory
				set thisTF to parent text frames of selection
			on error
				select nothing
			end try
			try
				set thisPage to my getParentPage(item 1 of parent text frames of selection)
				set {boxBottom, boxLeft} to {baseline of selection, horizontal offset of selection}
				
				--Now calc our boxTop & boxRight
				set boxTop to boxBottom - 1.5
				set boxRight to boxLeft + 1.5
				
				--and make them into a bounds list
				set boxCoordsList to {boxTop, boxLeft, boxBottom, boxRight}
				
				set myObject to make text frame with properties {geometric bounds:boxCoordsList, fill color:color tagBoxColor, stroke color:tagBoxStrokeColor, stroke weight:tagBoxStrokeWeight, item layer:tagLayer, label:tagLabel, text frame preferences:{ignore wrap:true, vertical justification:vertJust}, text wrap preferences:{«class txwt»:none}, contents:noteCounter as text} at page (document offset of thisPage)
				set applied character style of parent story of myObject to tagCharStyle
				set applied paragraph style of parent story of myObject to tagParaStyle
				select text of myObject
				set justification of selection to center align
				
				set thisReportEntryNum to noteCounter as text
			on error
				display dialog "Couldn't place Note Marker #" & noteCounter & "."
				set thisReportEntryNum to "" & noteCounter & " - NO MARKER"
			end try
			
			--Generate a report entry based on results
			set end of theReport to "Note #" & thisReportEntryNum & ", located on page: " & name of parent of «class pTxF» of thisNote
			set end of theReport to "Created by: " & user name of thisNote
			set end of theReport to "Creation date: " & (creation date of thisNote) as text
			set end of theReport to (text of thisNote) as text
			set end of theReport to "----"
			
			--increment note counter
			set noteCounter to noteCounter + 1
		end repeat
	end tell
	set nDoc to make new document
	tell active document
		set thisPage to first page
		try
			override first text frame destination page thisPage
		on error
			beep 1
			display dialog "ERROR: Your new document must have a master text frame. Please make a new document, check the \"Master Text Frame\" checkbox and click the Save Preset button. Choose \"[Default]\" from the list and replace the old default preset. Once you've done this, rerun the script and you should get the list of notes as expected." buttons "Cancel" default button 1
		end try
		set text of first insertion point of first text frame to my TextToList(theReport, return)
	end tell
end tell

on getParentPage(thisObject)
	tell application "Adobe InDesign CS4"
		if class of thisObject = page then
			return thisObject
		else
			return my getParentPage(parent of thisObject)
		end if
	end tell
end getParentPage

on TextToList(theList, thedelimiter)
	set text item delimiters to thedelimiter
	set theText to theList as text
	set text item delimiters to ""
	return theText
end TextToList

I don’t have CS4 so I can’t help you fix it, but I would be willing to bet that the problem is with this line:

set myObject to make text frame with properties {geometric bounds:boxCoordsList, fill color:color tagBoxColor, stroke color:tagBoxStrokeColor, stroke weight:tagBoxStrokeWeight, item layer:tagLayer, label:tagLabel, text frame preferences:{ignore wrap:true, vertical justification:vertJust}, text wrap preferences:{«class txwt»:none}, contents:noteCounter as text} at page (document offset of thisPage)

and this one:

set end of theReport to "Note #" & thisReportEntryNum & ", located on page: " & name of parent of «class pTxF» of thisNote

Most likely a change to the way ID works with text classes and text wrap preferences changed. For the first one look at the dictionary for text wrap preference, most likely the text wrap type has changed.

The second possibly has something to do with a change to the text frame identifier. You might try replacing “«class pTxF»” with “text frame” and see if it compiles, or look at the dictionary and see if there is a change to the “Text frame” class name.

One last potential problem, I believe that there are known issues with InDesign on Snow Leopard, so if you are on that OS this might be part of the problem as well.

Thanks,
I was able to add

else if idVersion = "6" then
			set tagCharStyleName to "[None]"
			set tagParaStyleName to "[Basic Paragraph]"

at the top of the script. This seemed to allow it to run in CS4.

Now when the script is run it says that it “Couldn’t Place Note Marker #1” and then spits out the following AppleScript Error:

"Adobe InDesign CS4 got an error: Can’t get name of parent of «class pTxF» of note id 7531 of story id 3758 of document “604_609_C21_S1_894586.indd”.

I assume that it has something to do with this portion

--Generate a report entry based on results
			set end of theReport to "Note #" & thisReportEntryNum & ", located on page: " & name of parent of «class pTxF» of thisNote
			set end of theReport to "Created by: " & user name of thisNote
			set end of theReport to "Creation date: " & (creation date of thisNote) as text
			set end of theReport to (text of thisNote) as text
			set end of theReport to "----"

Any suggestions?

Thanks,
Curt