Quark/Applescript - Missing data types in OS X?

I was in the process of converting some Quark XPress scripts over to OS X (10.2.4). I ran into a problem while getting properties of a picture box.

If I get the bounds of a picture box, it returns this:
«data FRMS006C0000006C000000D8000000D80000»

Interesting, says I, as the same command in Script Editor in OS 9 returns:
{“1.5"”, “1.5"”, “3"”, “3"”}

So I got the properties of the picture box (using Script Editor 1.9 in OS X) some of the properties are, how should I put this, “Wiggin’ out” comes to mind. Properties for rotation, shade, bounds and some items for frame (gap shade, shade, width, skew, text outset) are all returning «data» instead of what I would expect.

If I go back into OS 9, get the bounds of a picture box then get the class of the result, it says it’s ‘measurements rectangle’. My copy of AppleScript in a Nutshell doesn’t mention this data type AT ALL. (Same thing happens for the other ‘garbage’ properties - their classes are things like ‘percent’, ‘angle measurement’, ‘horizontal measurement’, etc)

Has anyone else experienced this? If so, here’s my guess - there are less know/hardly used data types that Quark uses but no one else does, so Apple pulled 'em from OS X. Or maybe these are QuickDraw data types. Or maybe my machine is screwed up - but I tried it on another Mac running 10.2.4 and it did the same thing.

Any thoughts?

Malcom

PS - Here’s the data class name and the 4 letter code that goes with them. The first 4 characters of the «data» string I guess are the type of data it is:

percent-'FX% ’
measurements rectangle-‘FRMS’
vertical measurement-‘FXVM’
horizontal measurement-‘FXHM’
angle measurement-'FX° ’
thick units-‘F_TH’
outset units-‘F_OU’

PSS - If I manually type this junk:
«data FRMS006C0000006C000000D8000000D80000»
into Script Editor for OS 9, it coerces it to:
{“1.5"”, “1.5"”, “3"”, “3"”}

:?

Hi :slight_smile:
You can use the “coerce” command of QXP:

coerce: Change data into a given type.
coerce anything
to type class – Type to coerce to.
[Result: anything]

Here one exemple:

tell application "QuarkXPress?"
	tell document 1
		set PropSel to properties of generic box 1
		
		log (rotation of PropSel) --> «data FX° 000F0000»*
		log (coerce (rotation of PropSel) to string) --> 15°
		
		log (shade of PropSel) --> «data FX% 00010000»
		log (coerce (shade of PropSel) to string) --> 100%
	end tell
end tell

:wink:

A big THANK YOU for pointing out the coerce command! :smiley:

It works, albeit a little cumbersome. But hey, I’ll take it!

So let me see if I got this coerce thing down. To get the bounds of a picture box as a list:


tell application "Quark"
	tell document 1
		set y1 to coerce (item 1 of (bounds of picture box 1 as list)) to real
		set x1 to coerce (item 2 of (bounds of picture box 1 as list)) to real
		set y2 to coerce (item 3 of (bounds of picture box 1 as list)) to real
		set x2 to coerce (item 4 of (bounds of picture box 1 as list)) to real
		
		set boundsList to {y1, x1, y2, x2}
	end tell
end tell

Right?

Malcom

Right !!! … :wink:

This is not working for me. I have the following that I’ve used successfully in Tiger:

tell application "QuarkXPress"
	activate
	set a to page width of document 1 as real --> 8.5
end tell

But in Leopard it fails:

tell application "QuarkXPress"
	activate
	--set a to page width of document 1 --> «data FXHM02640000»
	set a to page width of document 1 as real --> "cannot make data as real"
end tell

I believe I did the coerce correctly. It certainly did work before. I’ve verified it’s a Quark issue as I did not get the error in Filemaker 8.

What could it be? thanx, sam

I don’t have Leopard, so I can’t test it. I am infinitely curious if this solves the problem with Leopard because I will be moving to it eventually. I’m also curious as to which version of Quark is doing this, since that usually effects Quark’s applescript coercions, too. Filemaker has totally different object properties than Quark, mainly the ‘point units’ or ‘inch units’ (and others) for all measurements, bounds, and x/y points that look like strings or lists but aren’t, and the ‘as real’ coercion typically takes whatever is set in the document measurements preference. Maybe it doesn’t in Leopard but does in Tiger/Quark7 (which is what I’ve tested this).

tell application "QuarkXPress"
	activate
	set a to page width of document 1 as point units as real --> 612.0
	set a to page width of document 1 as inch units as real -->8.5
end tell

I will attempt this explicit coercion.

But as for more info, this is QXP 6.5.2 on both machines. I’ve verified that this is so on another Leopard machine. And I did restart the main Leopard machine to clear out any Script Editor garbage, so I’m positive that this is not it.

thanx, sam

Sam 6.5.2 is not supported in Leopard in fact its Pre-Tiger (although it runs well on mine) another question. Is your Leopard box Intel chipped? If so then Quark will be running under Rosetta I’ve not tried scripting 6.5.2 on my home mac which is Intel but you have to have your script editor and application both set to run on the same side of this. If that makes any sense to you I have not tried it so I don’t really know. I will have to take a look at some point though. I don’t have V7 but think is the first UB version of Quark so this may not happen.

Yes, I believe both of the Leopard machines are Intel. I was using Script Editor that was bundled with both.

What you say makes sense, thanx, sami

Sam, I am now at home with Quark 6.5.2 installed on my Imac (the latest intel thingy that won’t run Tiger). If I run pandrake’s sample using the installed Script Editior application it errors about data etc. However if I duplicate the “AppleScript” application folder then rename it “AppleScript Rosetta” and ditto with the name of the editor app inside I can now get info on the editor app and set to “Open using Rosetta” after this the script returns the values just fine. I don’t know if this is something that needs to be bared in mind with all non UB apps others here will know more about that stuff than me.

How about if you just change the 'Open using Rosetta" on the droplet created with an unmodified Script Editor?