Quark 2015 coerce to real

Discuss AppleScripting for QuarkXPress 2015, 2016 & 2017.

Quark 2015 coerce to real

Postby clagrangedli » 16 Nov 2015, 15:13

Below is part of a larger script that worked in previous versions but I can not get it to work in Quark 2015. Any suggestions?

tell application "QuarkXPress"
tell document 1
set thepw to the page width
set thepw to coerce thepw as real
end tell
end tell

error "Can’t make \"8.5\\\"\" into type real." number -1700 from "8.5\"" to real


Thank you
clagrangedli
 
Posts: 1
Joined: 16 Nov 2015, 15:06

Re: Quark 2015 coerce to real

Postby parpayoun » 21 Nov 2015, 03:56

Your code was almost good.
Just replace "as real" by "to real"

Code: Select all
tell application "QuarkXPress"
   tell document 1

      set vertical measure to millimeters
      set horizontal measure to millimeters

      set thepw to page width
      set thepw to coerce thepw to real

   end tell
end tell


Have fun!
;)
parpayoun
 
Posts: 7
Joined: 12 Jun 2004, 12:28

Re: Quark 2015 coerce to real

Postby Printer » 27 Nov 2015, 10:19

I'm experiencing the same problems as the OP and unfortunately your solution still creates an error:

QuarkXPress got an error: Can’t make some data into the expected type.

In earlier versions of Quark I was able to simply use:

tell document 1
set thepw to get page width as real
end tell

In Quark 10 It got more complicated and I found I had to coerce the variables to get a usable number:

tell application "QuarkXPress"
tell document 1
set docProp to properties
set thepw to (coerce (page width of docProp) to string)
display dialog thepw as string
set thepw to (coerce (page width of docProp) to real)
display dialog thepw as string
end tell
end tell

but even that doesn't work in Quark 2015

I'm using a workaround at the moment, I found the following handler on the net (thanks philastokes) to remove non numerical characters from a string and convert to a number:

on returnNumbersInString(inputString)
set s to quoted form of inputString
do shell script "sed s/[a-zA-Z\\']//g <<< " & s
set dx to the result
set numlist to {}
repeat with i from 1 to count of words in dx
set this_item to word i of dx
try
set this_item to this_item as number
set the end of numlist to this_item
end try
end repeat
return numlist
end returnNumbersInString

and then using the lines below to run the handler to get page width as a number

set thepw page width
tell me to set thepw to returnNumbersInString(pw)

each release of Quark seems to make Applescript's syntax logic harder to cope with

any help greatly appreciated
Printer
 
Posts: 4
Joined: 27 Nov 2015, 09:51

Re: Quark 2015 coerce to real

Postby Printer » 06 Jan 2016, 04:31

Is this Forum still active?
Printer
 
Posts: 4
Joined: 27 Nov 2015, 09:51

Re: Quark 2015 coerce to real

Postby pjanssen » 06 Jan 2016, 04:43

It's a shame, but unfortunately not many resources are spent into applescript development. I guess "coerce" is completely deprecated now.

So you'll need your own sub-routines to convert values from QuarkXPress.
pjanssen
 
Posts: 125
Joined: 31 Dec 1969, 19:00

Re: Quark 2015 coerce to real

Postby Printer » 07 Jan 2016, 04:33

Thanks for your reply pjanssen

It seems to me that Quark have not updated their QXPScriptingAdditions.osax scripting addition to run in the new 64-bit OS

Its a shame because the new Quark 2015 version seems to be very good, but without full applescript support they will struggle to regain market share back from Adobe IMHO
Printer
 
Posts: 4
Joined: 27 Nov 2015, 09:51

Re: Quark 2015 coerce to real

Postby pjanssen » 07 Jan 2016, 05:16

Only a few people use Applescript, so for them (Quark) it's logical to spend their resources on other stuff. Unfortunately for us few it would be not logical to do that... ;)
pjanssen
 
Posts: 125
Joined: 31 Dec 1969, 19:00

Re: Quark 2015 coerce to real

Postby Jean-Marie Schwartz » 07 Jan 2016, 05:41

To be honest, I'm still on v9 on purpose. I fear losing quantity of very useful scripts of mines by switching to 2015. I know I'm losing sth else in counterpart but… hard to make the jump. So reading this…
Jean-Marie Schwartz

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.10.4 • QuarkXPress 9.5.4.1 • Adobe CS5 =
Jean-Marie Schwartz
 
Posts: 2483
Joined: 23 Nov 2004, 04:30

Re: Quark 2015 coerce to real

Postby Jean-Marie Schwartz » 07 Jan 2016, 06:04

I've just open v2015 to see how it reacts with AS. I've simply created a new document with an empty text box and decided to see first wether regular Quark AS scripts shipping with the software would or not run properly. So I chose Box Tools > Make Caption Box.
I was surprised to see it works perfectly :)
So I open the script in my AS editor. I've run the script from there (gosh! © 1986-2006!) and bad luck: it errors "Impossible de convertir "60,286 mm" en type point units. [-1700]"
Don't know what to think of this. It means that our scripts would run properly straight from within Quark but we'll get white hair at blind-coding and testing our stuff.

I don't know nothing about Osaxen but I have the same feeling that the OSAX might be somehow obsolete. Don't know.
Jean-Marie Schwartz

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.10.4 • QuarkXPress 9.5.4.1 • Adobe CS5 =
Jean-Marie Schwartz
 
Posts: 2483
Joined: 23 Nov 2004, 04:30

Re: Quark 2015 coerce to real

Postby Printer » 11 Jan 2016, 06:40

Hi Jean-Marie

The second display dialog in the simple script below errors whether it is run in AS editor or from within the Quark Script menu unfortunately

tell application "QuarkXPress"
tell document 1
set docProp to properties
set thepw to (coerce (page width of docProp) to string)
display dialog thepw as string
set thepw to (coerce (page width of docProp) to real)
display dialog thepw as string
end tell
end tell

well no error displayed when run from with the Quark scripts menu, but just quietly quits with no quark error reporting as usual from Quark.

The "Make Caption Box" script you mentioned runs error free for me too
Printer
 
Posts: 4
Joined: 27 Nov 2015, 09:51

Next

Return to QuarkXPress 20xx: Scripting

Who is online

Users browsing this forum: No registered users and 1 guest