Quark Script almost done...

I was wondering if someone knows what could be wrong with this script. Application is Quark 4.11 operating in classic mode. Everything works (it takes a job number and sets a path via buttons then is SUPPOSED to save the Quark page as an EPS file in the given location.) The path seems to check out, however, I get the following error: “Cant make data into expected type”. I am having trouble understanding why. Here is the script… Thanks in advance.


set answerhold to display dialog "Enter Job Number (excluding leading zeros)" default answer ""
set filename to text returned of answerhold
if (count of result) is equal to 3 then
	set finalnumber to (characters -1 thru 1 of ("0000000" & filename)) as text
	
else if (count of result) is equal to 4 then
	set finalnumber to (characters -1 thru 1 of ("000000" & filename)) as text
	
else if (count of result) is equal to 5 then
	set finalnumber to (characters -1 thru 1 of ("00000" & filename)) as text
	
else if (count of result) is equal to 6 then
	set finalnumber to (characters -1 thru 1 of ("0000" & filename)) as text
	
else if (count of result) is equal to 7 then
	set finalnumber to (characters -1 thru 1 of ("000" & filename)) as text
end if

tell application "QuarkXPressâ„¢ 4.11"
	display dialog "Choose destination..." buttons {"C^", "R^", "S^"}
	set theChoice to button returned of result
	if theChoice is "C^" then
		tell application "QuarkXPressâ„¢ 4.11"
			set DestinationFolder to "HIGH RES ART:C:" as text
			set NewDocPath to ((DestinationFolder as text) & theChoice & finalnumber) as string
		end tell
		
	else if theChoice is "R^" then
		tell application "QuarkXPressâ„¢ 4.11"
			set DestinationFolder to "HIGH RES ART:R:" as text
			set NewDocPath to ((DestinationFolder as text) & theChoice & finalnumber) as string
		end tell
		
	else if theChoice is "S^" then
		tell application "QuarkXPressâ„¢ 4.11"
			set DestinationFolder to "HIGH RES ART:S:" as text
			set NewDocPath to ((DestinationFolder as text) & theChoice & finalnumber) as string
		end tell
	end if
end tell


tell application "QuarkXPressâ„¢ 4.11"
	activate
	tell document 1
		save in NewDocPath as file type EPS format Mac black and white EPS data binary EPS with OPI  --this is the line that errors out.
	end tell
end tell

The last tell statement should read something like:

tell application "QuarkXPressâ„¢ 4.11"
	activate
	tell document 1
		save page 1 in (NewDocPath as alias) EPS format Mac black and white EPS data binary EPS OPI include images
	end tell
end tell

I believe you can only save 1 page at a time as an EPS, and your OPI statement was incorrect as well as the file path.

You could probably speed this up by only doing the one call to quark for the actual save among other things

Next time for troubleshooting- try hard coding a file path. I find I often declare file paths incorrectly for one reason or another. If I can write a text file to the same path I know that part is OK. You also might want to read the applications AS dictionary.

-N

Thanks to lewiscot’s entry to another user my problem has been solved by the following lines…

tell application “QuarkXPressâ„¢ 4.11”
activate
save page 1 of document 1 in file NewDocPath EPS format Mac color EPS data binary EPS OPI include images scale 100 bleed 0.125 with include preview
end tell

THANKS TO ALL INVOLVED!