Postscript problem

hi,

can anyone tell me what the problem is with my script? the problem is on the print line… i think. this is my first script so please excuse any glaring errors.

thanks
cathryn :slight_smile:

tell application “Macintosh HD:Applications (Mac OS 9):QuarkXPress 4.11:QuarkXPress™ 4.11”
activate
open “Data:Jobs:00041PongrassCommunications:WorkingFiles:00041C_D”
DataFile Path “Data:Jobs:00041PongrassCommunications:Database:0355194_0371208.txt”
set loopCount to 13808
set myNumber to loopCount
repeat until loopCount > 16015
if myNumber < 16015 then
tell application “Macintosh HD:Applications (Mac OS 9):QuarkXPress 4.11:QuarkXPress™ 4.11”
ExportPrint RecordStart myNumber RecordEnd myNumber + 499 OutputFile “Data:Jobs:00041PongrassCommunications:Print:00041C_D:in:00041c_d_” & myNumber
end tell
set filePath to “Data:Jobs:00041PongrassCommunications:Print:00041C_D:in:00041c_d_” & myNumber
tell application “Macintosh HD:Applications (Mac OS 9):QuarkXPress 4.11:QuarkXPress™ 4.11”
tell “Data:Jobs:00041PongrassCommunications:WorkingFiles:00041C_D”
print PostScript file filePath
end tell
end tell
repeat
if not (ExportPrintBusy) then exit repeat
end repeat
set loopCount to loopCount + 500
tell application “Macintosh HD:Applications (Mac OS 9):QuarkXPress 4.11:QuarkXPress™ 4.11”
ExportPrint RecordStart 15807 RecordEnd 16015 OutputFile “Data:Jobs:00041PongrassCommunications:Print:00041C_D:in:00041c_d_00041c_d_15807.ps”
end tell
set filePath to “Data:Jobs:00041PongrassCommunications:Print:00041C_D:in:00041c_d_15807.ps”
tell application “Macintosh HD:Applications (Mac OS 9):QuarkXPress 4.11:QuarkXPress™ 4.11”
tell “Data:Jobs:00041PongrassCommunications:WorkingFiles:00041C_D”
print PostScript file filePath
end tell
end tell
repeat
if not (ExportPrintBusy) then exit repeat
end repeat
GeneralOption JPF 0
close document 1
GeneralOption JPF 1
end if
end repeat
end tell

Okay, there are a lot of problems here, I haven’t scripted Quark in a while, and I don’t use Classic at home (since OSX Beta), so some of what I’ll suggest might be vague.

First off, you don’t need to define the path to the app (in OS9, if you’re scripting for Classic, this might be a limitation, I don’t know). You can just use: tell app “QuarkXPress™ 4.11” (if it is a limitation of scripting Classic, you can set a variable to the path and reference that, i.e. tell app quarkPath). Also, the whole script is wrapped in a tell Quark block so you can and should eliminate every tell Quark block that you have nested within.

What is this: DataFile Path “Data:Jobs:00041…” ‘DataFile’ and ‘Path’ are not defined variables and aren’t apart of QXP’s dictionary, so this should cause an error and shouldn’t even compile.

Same with: ExportPrint RecordStart myNumber RecordEnd myNumber + 499 OutputFile. ‘ExportPrint’, ‘RecordStart’, ‘RecordEnd’, and ‘OutputFile’ aren’t defined variables and aren’t in Quark’s dictionary.

And again: if not (ExportPrintBusy) then. Where is ‘ExportPrintBusy’ defined?

And again: GeneralOption JPF 0 and GeneralOption JPF 1.

To define a variable, for the most part you use ‘set’ as in: set ExportPrintBusy to true. There are also properties, but I won’t get into that.

For addressing a document (tell “Data:Jobs:00041…”), I’m certain you shouldn’t use its path and am pretty sure you can just address it by name as in: tell document “00041C_D”. (I’ll check these at work to verify.) Another way is to address it by its index, i.e. tell document 1, or by its relative index, i.e. tell front document.

With the ‘open’ call followed by a text path, is that working? Quark might be different but usually you would use: open file “yourText:pathTo:theFile”.

My overall suggestion would be to step back and do some very basic things first. Tell Quark to open your document. Does that work? Tell your document to print postscript file yourFilePath with options {yourPSOptions}. Does that work? You can clean up your script by removing a lot from within the repeat loops and placing them in handlers as in:

on printQXPS(thisDocument, savePath, psOptions)
tell document thisDocument of app “QuarkXPress™ 4.11” to print postscript etc…
return true
end printQXPS

Add comments. Comments in scripts remind you what exactly you’re doing and are essential when you come back to the script months or years later. For complicated scripts, many times I start out with just comments outlining the algorithm, then I fill in the script statements and test each addition as I go.

And then there’s error handling, but I’ve got to get to work now, so I’ll post back later.

Thanks Joseph,

I’ll have a look at those things. The Datapath, ExportPrint etc are for a plug-in in quark and have their own dictionary.

It errors usually -120 or -48 on the print line.

I will try the things you have suggested and post again later.

Thanks heaps,
Cathryn :slight_smile:

I have a script for Quark running under 9.1 that prints PS files.

I have the following in my code and it works…


--within Tell Quark context
Tell print setup
set data format to binary data
end tell

print PostScript file filePath OPI include images

I also switch my printer to the one that is going to build the PS file
before printing it.

Good luck!

Thanks I’ll give that a try also and post again later.

Thanks heaps,
Cathryn :slight_smile:

That explains a lot, though I won’t be able to help you with those parts.

I checked some things at work and yes, you can’t address a document with a path, just use the name. And you will need to change the open statement to: open file “textPath:toFile”

I’m baffled at what’s going on in this script. Does the plug-in incorporate some kind of dataset manipulation? Does it append data to the postscript? Or to the Quark doc? Or is it just for some kind of versioning? Since the script only addresses one document and it looks like you’re outputting to a Distiller watched folder, I figure something like this must be going on. Speaking of addressing one document, is this just a test setup? I’d imagine you’d want it to be a little more applicable.

Any way you look at it, you’ve got a complicated little task there for your first script. Good luck.

Oh, as far as the error handling goes, you wouldn’t want to implement that until you’re done anyway since you want to know what’s going wrong. It’s mostly for the end when you’re ready to deploy. But when you are, it goes something like this:

try
– the instructions you hope will succeed
on error – something went wrong
– the on error section gives you a chance to clean up after the error
– and maybe log what went wrong
end try