MAC OS 9 and Quark 3.32 Scripting Questions

Hi!

I’m a newbie at Apple Scripting and already got some big problems. I’ve read that Quark Xpress is scriptable an i want to do this with an apple script.
First of all I’ve got to open a box smaller than 25,4 mm in Quark via Apple Script.
If I’m not able to do so an alternative would be to open a box with 10 mm added above and below the real box and cut if off when it comes to export the *.eps. Also I want Quark only to show the colors in my Apple Script as default. All the other Colors must be inactive or not available. The colors I provide to Quark via Script are variable.
It comes to another problem when i want to give Quark a destination Path for my eps-Export. It always goes to the Application Folder. It has to go to the same folder i used for the Quark-Dokument. Is the any way to solve these problem with an Apple Script?

It has been a looong time since I’ve scripted QXP 3 so the language may be a little different than what I’ve done here. I wasn’t sure if you meant that you want to add the 10 mm boxes above and below the page or above a picture box so I went with a picture box.


tell application "QuarkXPress™"
set horizontal measure of document 1 to millimeters
	set vertical measure of document 1 to millimeters
	tell document 1
		set pWidth to page width as real
		set pHeight to page height as real
		tell page 1
			set {x1, y1, x2, y2} to bounds of picture box 1 as list
			set {x1, y1, x2, y2} to {x1 as real, y1 as real, x2 as real, y2 as real}
			make new picture box at beginning with properties {bounds:{x1 - 10, y1, x1, y2}}
			set suppress printing of picture box 1 to true
			make new picture box at beginning with properties {bounds:{x2, y1, x2 + 10, y2}}
			set suppress printing of picture box 1 to true
		end tell
	end tell
end tell

Since the “suppress printing” property has been set to “true” the newly created boxes will not appear on the EPS file. If you need to actually delete them, you will have to give each of the boxes a name, then have your script delete the objects by name.

For the colors, you will have to delete all the colors you don’t want to appear but you cannot delete White, Black, Registration, Cyan, Magenta or Yellow.

For exporting the EPS file, I am assuming you are using the “save to eps file” command. To do this, you will need to pass a full path to the command. Here is how to save the EPS file in the same folder with the original document:


tell application "QuarkXPress™"
	set fPath to file path of document 1 as string --make sure you specify "string". The default is an alias and won't work
	set fName to name of document 1
	set AppleScript's text item delimiters to ":"
	set fPath to every text item of fPath as list
	set fPath to items 1 thru ((count items of fPath) - 1) of fPath as string
	set AppleScript's text item delimiters to ""
	set fPath to fPath & ":" & fName & ".eps" as string
	save page 1 of document 1 in file fPath EPS format Mac color EPS data binary EPS OPI include images with include preview
end tell

Keep in mind that if the QXP document has not been previously saved, the file path will be returned as null so you’ll have to save the QXP document first.

A great way to figure out the language for referring to objects with AppleScript is to have AppleScript return the properties of the object in question. Here is an example with QuarkXPress


tell app "QuarkXPress"
return properties of document 1
end tell

From the record that is returned from this code you will be able to see how QuarkXPress expects you to refer to objects and what properties belong to this object. In the code above we used the “file path” property of the original document. We then trimmed off the file name so that we were left with the enclosing folder. Be sure to specify that the file path is returned as a string since the default return will be an alias.

Good luck. I’ll continue to check this post in case you have any more questions. Also, check the “unScripted” section of this site as I plan to do an article in the coming weeks on very practical coding and trouble-shooting techniques.

Hope this helps.

Scott Lewis