Difference between "do script" and "run"? (QuarkXPress 7)

Hi there,

Recently, I’ve been trying to figure out why QuarkXPress 7 loves to crash on our applescripts.

While looking through the code that’s causing the crash, I’ve noticed a (for me) strange behavior.
In a sub script, We’re trying to create a text box, manipulate it, and then delete it again. If that operation fails, we’ll return true and an error log with number, or return false otherwise.

For some strange reason, when I call the script via “do script” then the return value is different (true) from when I run it using the “run” command (false).

Any ideas why/how this is happening? Any help would be greatly appreciated.

(btw. I’m running this on OSX 10.5.8, QuarkXPress 7)

Here’s the code sample (I’ve ommitted the irrelevant parts, so ignore some logical weirdness):


property P_TypeToCheck : "style"

try
	if P_TypeToCheck = "style" then
		tell application "QuarkXPress Passport"
			--set myResult to do script {qxp_style} -- this returns true
			set myResult to run qxp_style -- this returns false
		end tell
	else
		error "This \"" & P_TypeToCheck & "\" is not supported!"
	end if
on error errMsg
	error "BadBehaviors: " & errMsg
end try

script qxp_style
	try
		tell application "QuarkXPress Passport"
			tell document 1
				set myBox to make new text box at beginning ¬
					with properties {bounds:{0, -10, 5, -5}, name:"qxp_style", suppress printing:true}
				set text of myBox to "X"
				set myStyle to a reference to style spec "Normal"
				set myCharStyle to a reference to character spec "Normal"
				tell text box "qxp_style"
					set x to object reference
					tell text 1
						set style sheet to myStyle -- this is where the try breaks when using "do script" instead of "run"
						set character style of character 1 to myCharStyle
					end tell
				end tell
			end tell
			try
				delete text box "qxp_style" of document 1
			end try
		end tell
		return false
	on error errMsg number errNum
		try
			tell document 1 of application "QuarkXPress Passport" to delete text box "qxp_style"
		end try
		if errNum = -10006 then
			return true
		else
			error "script qxp_style: " & errMsg
		end if
	end try
end script

Model: iMac
AppleScript: 2.0.1
Browser: Firefox 3.5.5
Operating System: Mac OS X (10.5)