need advice on why QuarkXPress script alters behavior when an App.

G’day

The following script works OK when used as a script, but when used as an Application, it crashes. The error occurs in the ‘set T to T as real’ line, and generates an error ‘Can’t make <> into type real’.

Any advice please?

Regards

Santa


on QuarkMake_CropMarks(ThisBox)
	tell application "QuarkXPress"
		tell document DocName
			tell current page
				try
					say "cropmarks"
					copy (coerce (bounds of ThisBox as points rectangle) to list) to {T, L, B, R}
					say "cropmarks 2"
					set T to T as real
					set L to L as real
					set B to B as real
					set R to R as real
					
					set L1 to L - CropMarks_Offset - CropMarks_Length
					set L2 to L - CropMarks_Offset
					set R1 to R + CropMarks_Offset
					set R2 to R + CropMarks_Offset + CropMarks_Length
					set T1 to T - CropMarks_Offset - CropMarks_Length
					set T2 to T - CropMarks_Offset
					set B1 to B + CropMarks_Offset
					set B2 to B + CropMarks_Offset + CropMarks_Length
					say "cropmarks 3"
					
					set Crop1 to make new line box at end with properties {start point:{T, L1}, end point:{T, L2}, width:CropMarks_Thickness}
					set Crop2 to make new line box at end with properties {start point:{T, R1}, end point:{T, R2}, width:CropMarks_Thickness}
					set Crop3 to make new line box at end with properties {start point:{B, L1}, end point:{B, L2}, width:CropMarks_Thickness}
					set Crop4 to make new line box at end with properties {start point:{B, R1}, end point:{B, R2}, width:CropMarks_Thickness}
					
					set Crop5 to make new line box at end with properties {start point:{T1, L}, end point:{T2, L}, width:CropMarks_Thickness}
					set Crop6 to make new line box at end with properties {start point:{B1, L}, end point:{B2, L}, width:CropMarks_Thickness}
					set Crop7 to make new line box at end with properties {start point:{T1, R}, end point:{T2, R}, width:CropMarks_Thickness}
					set Crop8 to make new line box at end with properties {start point:{B1, R}, end point:{B2, R}, width:CropMarks_Thickness}
				on error theerror number errNum
					say "error in cropmarks"
					display dialog theerror
					set Crop1 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
					set Crop2 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
					set Crop3 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
					set Crop4 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
					
					set Crop5 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
					set Crop6 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
					set Crop7 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
					set Crop8 to make new line box at end with properties {start point:{0, 0}, end point:{0, 0}, width:CropMarks_Thickness}
				end try
			end tell
		end tell
	end tell
	return {Crop1, Crop2, Crop3, Crop4, Crop5, Crop6, Crop7, Crop8}
end QuarkMake_CropMarks

OK, I solved that one with this…


--copy (coerce (bounds of ThisBox as points rectangle) to list) to {T, L, B, R}
					--copy (coerce (bounds of ThisBox as points rectangle) to list) to {T, L, B, R}
					set T to coerce (item 1 of (bounds of ThisBox as list)) to real
					set L to coerce (item 2 of (bounds of ThisBox as list)) to real
					set B to coerce (item 3 of (bounds of ThisBox as list)) to real
					set R to coerce (item 4 of (bounds of ThisBox as list)) to real
					
					

but now I’ve struck another part of my script where that method doesn’t work, and neither does anything else I’ve tried. Again, any ideas please.

Regards

Santa


on QuarkSize_ThisGroup()
	tell application "QuarkXPress"
		try
			tell document DocName
				set TheRef to (object reference of selection)
				-- These don't work
                                try
					set theBounds to (bounds of TheRef)
					set PlacingWidth to (width of theBounds) as real
					set PlacingHeight to (height of theBounds) as real
				on error
					set PlacingWidth to coerce (width of TheRef as inch units) as real
					set PlacingHeight to coerce (height of TheRef as inch units) as real
				end try
				my QuarkDoMenu("Edit", "Cut")
				
			end tell
			set end of QuarkFileList to ThisItem as string
			set end of QuarkSizeList to (PlacingWidth as integer)
			set end of QuarkAreaList to PlacingWidth * PlacingHeight
			set end of QuarkPrintedList to false
		on error theerror number errNum
			display dialog theerror
		end try
	end tell
end QuarkSize_ThisGroup