Upgrading Quark Automation Scripts from OS 9 to OSX

Are you one of the holdouts still on OS 9 You’ve got an automated process, and it works great. It’s not broken, so why change anything

Change is inevitable and constant, particularly in the field of technology. MacOSX is a change for the better. It’s faster. I discovered this while working with a colleague who was running the same Filemaker system on faster hardware. We were both performing a replace on the same data set using Filemaker 6.0v3. My system finished the replace in half the time despite my slower hardware. The difference I was running OSX.

Even if you feel your system is “fast enough” and you are not interested in the myriad of widgets available for OSX, you will still eventually have to upgrade, because something required by your automation process will irreparably break and whatever you replace it with will not be compatible with OS 9. You must move on. The sooner you do, the fewer changes you will have to make, and the less painful it will be.

Many people who are hesitant to upgrade because of automated processes using Quark. I can relate to this reluctance. I’ve worked with Quark for years and have struggled through seemingly innocuous upgrades like 4.0 to 4.1 that broke print automation systems. The general rule of thumb has been, if it involves Quark and it works flawlessly, don’t even breathe on it.

I anticipated quite a struggle when my first brave client stepped up to the plate wanting to upgrade their system. This particular client had nothing to lose. They had already abandoned their Quark automation system that was developed in 9 because of Quark’s tendency to lose the graphics. They were hoping this problem would be remedied by Quark’s version for OSX. I didn’t have high hopes, but was willing to try.

To my amazement, the script compiled and ran on OSX almost without a hitch! This script worked in conjunction with Filemaker, retrieving data, selecting a Quark template, and creating the document. The specific commands within Quark that needed no adjustments automated picture import, changed horizontal and vertical measure to points, listed the fonts of the document, created text boxes with different sets of bounds (in points), entered text, set fonts, styles and sizes, then named, saved, and closed the document. All of that worked pretty well. Going from Filemaker 6 on OS 9 to Filemaker 6 on OSX required no changes. Even the applescript for the Finder that checked for the existence of folders and created them where necessary needed no adjustments.

There were only two problems. The first problem was that paragraph breaks in OSX are not the same as they were on OS 9. The old method of “\r” doesn’t work. To get paragraph breaks to show up reliably in Quark, I set a variable to ascii character 13 and plug in that variable where ever I want a paragraph break.

set pb to ASCII character 13

-- (Pb stands for paragraph break.)

set mytext to "Dear So-and-so, " & pb & "I'm writing to inform you that the paragraph breaks in your applscript need to be changed..."

The second problem was that Quark for OSX can’t seem to accurately count lines. It likes to add one to the total number of lines. I found that a little extra error checking and subtracting one from the total number of lines reported by “count lines of paragraph 1 of newbox” remedied this problem.

In addition to those two adjustments, one addition specific to OSX was helpful. The default name for PDF’s printed from Quark documents in OSX is the name of the layout. Setting the name of the layout was a little tricky. The dictionary indicates that the layout is an object within the document, but calling on name of layout 1 of document 1 doesn’t work. Instead, you have to refer to the name of the layout space within the project:

set name of layout space 1 of project 1 to "My New Name"

A second script that updated information in the Quark document by obtaining the name of a graphic used within the Quark document needed no changes.

After several months of running the upgraded version of these scripts on OSX, Quark has lost no graphics. Not only was this upgrade surprisingly easy, problems with the previous version of Quark have been eliminated.

A short time after this upgrade, another client contacted me with an even more intricate script to upgrade. His automation process also took information from Filemaker and entered it into Quark, but it made multiple pages from scratch, selecting different layouts and pulling in graphics. Even with this more complex script, nothing more than the two previously mentioned items needed adjustments. In addition to the Quark script, he had another script that uploaded graphics to an FTP site to serve on the web using the URL Access scripting addition. The OSX version of that osax had an incompatibility with WebStar’s simple FTP server running on OS 9, but that was the only problem encountered in upgrading his complex solution.

Scripting additions used in your scripts are another factor that you will want to consider when making the leap from OS 9 to OSX. Make sure that OSX compatible versions of all the osax called in your scripts are included in your OSX system. Your Quark script might also use extensions installed in Quark, so be sure that OSX compatible versions of all relevant Quark extensions are installed in OSX before you try to upgrade your old scripts. If you are using a Quark print automation, I recommend that you only upgrade to Panther for now (OSX 10.3). There are problems with scripted printing in Quark using Tiger (OSX 10.4). I have not yet scripted any print automations in Quark, but if you plan to automate your printouts, you’ll want to check out the dictionary of the Printer Setup Utility in to set the current printer:

tell application "Printer Setup Utility"
set current printer to printer "Stylus Photo R200"
end tell

If you’re not sure how to refer to the printer you want, set your desired printer to the current printer manually and, run:

tell application "Printer Setup Utility"
return current printer
end tell

In Quark, checking out the print setup record in the ancillary objects of the Quark dictionary will give you a lot of settings to tweak.

In summary, the minimal pain that you should encounter when upgrading your Quark automation scripts is well worth the effort.

Happy Upgrading!

Amended 2/15/06

One more suggestion for upgrading your scripts:

Add the term “file” in front of the filepath to the image when you set the image of a picture box:


tell application "QuarkXPress"
	set image 1 of newbox to file thepath
end tell

Also, look for my later article on working with horizontal scaling with the newer version of Quark.