Batch print QXPs and add Approval mark does not work on another mac

Hi all,

I have a script that will batch print qxp files dropped onto this app and add a 1st APPROVAL stamp outside the print area.

This has undergone several versions and has been working fine on more than 1 mac.

Now when I have added the part that sets pWidth to the width of the current document to enable the 1st APPROVAL text box to be positioned in relation to the page size, the script no longer works on another mac. It does work fine on my mac!
The error I get is “Can’t make <> into type integer”

Any reason for this??

PS. if I change the “as integer” part to “as real” the error message changes to reflect this change!!

the code:-


on open these_items
	
	repeat with i from 1 to the count of these_items
		set this_item to (item i of these_items)
		set the item_info to info for this_item
		
		if folder of the item_info is true then
			process_folder(this_item)
		else if (alias of the item_info is false) then
			my process_item(this_item)
		end if
	end repeat
end open

on process_folder(this_folder)
	set these_items to list folder this_folder without invisibles
	repeat with i from 1 to the count of these_items
		set this_item to alias ((this_folder as text) & (item i of these_items))
		set the item_info to info for this_item
		if folder of the item_info is true then
			process_folder(this_item)
		else if (alias of the item_info is false) then
			my process_item(this_item)
		end if
	end repeat
end process_folder



on process_item(this_item)
	tell application "Finder"
		try
			set File_Name to name of file this_item as text
			
		on error
			display dialog "Bad"
		end try
	end tell
	
	--Force Default printer to Bahamas
	
	tell application "Printer Setup Utility"
		set current printer to first printer whose name is "Bahamas"
	end tell
	
	tell application "QuarkXPress"
		open this_item use doc prefs «constant KPRFyes »
		
		--Check for missing or modified images and warn!
		try
			tell document 1 to set modPics to count of (every picture box whose modified of image 1 is true)
			if modPics > 0 then tell every page of layout space 1 of project 1
				make new text box at beginning with properties {bounds:{"147.847 mm", "28 mm", "198.533 mm", "197.631 mm"}, runaround:none runaround, vertical justification:top justified, rotation:"15°"}
				set story 1 of text box 1 to "MISSING OR MODIFIED IMAGES FOUND"
				set size of story 1 of text box 1 to 26
				set font of story 1 of text box 1 to "321impact"
				set shade of story 1 of text box 1 to "100%"
			end tell
			
		end try
		
		set pWidth to page width of document 1 as integer
		set pHeight to page height of document 1 as integer
		set page rule origin of document 1 to {"0mm", "0mm"}
		tell every page of layout space 1 of project 1
			make new text box at beginning with properties {bounds:{pHeight - 3, pWidth / 2 - 30, pHeight + 31, pWidth / 2 + 50}, runaround:none runaround, vertical justification:bottom justified, opacity:"70%"}
			set story 1 of text box 1 to "1st APPROVAL"
			set size of story 1 of text box 1 to 30
			set font of story 1 of text box 1 to "HelveticaNeue BoldCond"
			set shade of story 1 of text box 1 to "70%"
		end tell
		
		--print it
		
		with timeout of 5 * minutes seconds
			tell document 1
				tell print setup
					set printer type to "Xerox WorkCentre Pro 255"
					set paper size to "A3"
					set orientation to portrait
					set page position to center position
					set print spreads to false
					set fit in area to false
					set reduce or enlarge to 100
					set registration marks to centered
				end tell
				tell custom bleeds setup 1
					set bleed type to asymmetric
					set bleed to {"3mm", "3mm", "150mm", "3mm"}
					set bleed clipping to true
				end tell
			end tell
			print document 1 copies 1
			close document 1 saving no
		end timeout
	end tell
	
end process_item

Thanks in advance

Hi,

Have you tried:


set pWidth to (coerce page width of document 1 to integer)
set pWidth to (coerce page width of document 1 to real)

Hi Martin Michel,

Thanks for the quick reply!

I’ll have a look at this tomorrow when I’m back at work.

I did forget to mention that I can “set pWidth to page width of document 1 as integer”
then “get pWidth” in a separate script, on a page I am trying to print!

It only seems to be a problem within this script on a particular Mac.

Thanks again!

The coercion problems are well known to people scripting QXP :smiley:

I first encountered them when porting scripts from Mac OS 9/Classic to Mac OS X…

So, good luck :slight_smile:

You don’t say what version of Quark you are running? and on what type mac box? a very common reason for errors like ‘<>’ is shifting an AppleScript app to intel chipped box. Can you give more details? Your script app and target app need to be working on the same side of Rosetta is the Quark in question 6.5?

Hi Mark67,

It’s Quark 7 and G5 Macs. As far as I know neither of them are intel machines!!

I will check once I get to work again.

Thanks for all help & advice.

intoto.

Mark67,

I have just checked and the two machines do differ! The mac on which the script was written is a G5 Power PC and the other machine is indeed an intel machine! (Both are running Quark 7.31 and the same OS X (10.4.11))

As yet I have not had a chance to try the “coerce page width” solution posted by Martin Michel.

Is there a way around this problem?

Thanks, as always…

Your Version of Quark is UB so if you compiled your app on the G5 mac it will be under Rosetta. When moved as an app to the Intel mac you will get this cross chatter. Open you Script in Script Editor on the Intel and re-compile then save. Do get info just to check that the check box for Rosetta emulation is NOT checked.

OK guys,

I have had a little time to try out your suggestions. Without any success!

Firstly, I tried recompiling the original script on the intel machine and still get a similar error message to the original one. It just seems as though the data code has changed to - “<> into type integer” or /number/real etc. I did a get info (on the script application) but cannot find the Rosetta emulation check box! (Am I being dumb??!)

Secondly I tried the coercion method as suggested by Martin Michel and this time I get an error message “Can’t make some data into the expected type”

Any more thoughts would be much appreciated.

intoto…

Hi,

If I run the following snippet on a G5 in Mac OS X’s Script Editor to address a QXP 3 running in Classic I get problems:


tell application " QuarkXPressâ„¢"
	activate
	tell document 1
		set pw to (coerce page width to real)
	end tell
end tell
-- throws an exception

But the following code works just fine:


tell application " QuarkXPressâ„¢"
	activate
	tell document 1
		set pw to page width
		set pw to (coerce pw to real)
	end tell
end tell

Had to rewrite a lot of scripts because of those problems…

Just to update everyone…

I have solved this problem (for now anyway!)

It would seem that the problem was that the bounds of the new text box for the approval text did not like doing the maths!

I have now pre-defined a x coordinate, y coordinate, box height and box width (based on the page size) as variables that can be called into the bounds singularly!

It seems to work!

Thanks for everyones input!

intoto.