Monday, May 20, 2019

#1 2019-05-12 08:07:09 pm

johnmathew
Member
Registered: 2009-10-12
Posts: 94

Script worked on Quark 9.5 and not working in Quark 2017

Hi Guys,

I am using Mac OS Sierra - Version 10.12.6, Quark Xpress 2017 and Script Editor 2.5

Below Script works fine in Quark 9.5 and not working in Quark 2017

Showing Coercing Error

Applescript:

tell application "QuarkXPress"
activate
tell document 1
set horizontal measure to picas
set vertical measure to picas

set theSelection to selection
set values to {horizontal offset of theSelection}
set values1 to {width of theSelection}
set values to coerce values to real
set values1 to coerce values1 to real

get bounds of current box
set y1 to coerce (item 1 of (bounds of current box as list)) to real
set x1 to coerce (item 2 of (bounds of current box as list)) to real
set y2 to coerce (item 3 of (bounds of current box as list)) to real
set x2 to coerce (item 4 of (bounds of current box as list)) to real

set boundsList to {y1, x1, y2, x2}
try
tell current page
set values to values + x1
make vertical guide at beginning with properties {position:values}
set values1 to values1 + values
make vertical guide at beginning with properties {position:values1}
end tell
end try
end tell
end tell

Throws the below error.

Applescript:

tell application "QuarkXPress 2017"
activate
set horizontal measure of document 1 to picas
set vertical measure of document 1 to picas
get selection of document 1
--> text from character 460 to character 465 of text flow 1 of text box 1 of document "Project1.qxp"
get horizontal offset of text from character 460 to character 465 of story 1 of text box 1 of document "Project1.qxp"
--> "4p4.687"
get width of text from character 460 to character 465 of story 1 of text box 1 of document "Project1.qxp"
--> "2p6.012"
coerce {"4p4.687"} to real
--> error number -1700
Result:
error "QuarkXPress 2017 got an error: Can’t make some data into the expected type." number -1700 to item

Offline

 

#2 2019-05-13 02:35:40 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 122

Re: Script worked on Quark 9.5 and not working in Quark 2017

johnmathew wrote:

Hi Guys,

I am using Mac OS Sierra - Version 10.12.6, Quark Xpress 2017 and Script Editor 2.5

Below Script works fine in Quark 9.5 and not working in Quark 2017



coerce {"4p4.687"} to real works FINE at old version? It's hard to believe, as this expression contains letter "p", which can't be coerced to number (integer or real).

What is the number of "p"? Think for yourself. If the old version does not throw an error with this expression, then it would be more logical to think that this is a bug of the old version.

Last edited by KniazidisR (2019-05-13 02:42:55 am)


macOS Mojave -- version 10.14.4
Safari -- version 12.1

Offline

 

#3 2019-05-13 03:20:43 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4868

Re: Script worked on Quark 9.5 and not working in Quark 2017

KniazidisR wrote:

coerce {"4p4.687"} to real works FINE at old version?


It probably means the old version returns something different for the 'horizontal offset'. I can't see why the script code should be putting the result into a list, only then to coerce the list to real.


NG

Offline

 

#4 2019-05-13 07:21:45 pm

johnmathew
Member
Registered: 2009-10-12
Posts: 94

Re: Script worked on Quark 9.5 and not working in Quark 2017

Hi,

What is the number of "p"?



It is the Picas Measurement in Quark (like Millimeter, Inches etc.,)

Without Coercing, the script doesn't work in Older version.


Thanks

Offline

 

#5 2019-05-14 01:56:47 am

CMYS
Member
From:: Belgium
Registered: 2007-07-02
Posts: 86

Re: Script worked on Quark 9.5 and not working in Quark 2017

I'm pretty sure Nigel pointed the real issue: "the old version returns something different for the 'horizontal offset'."
In Quark, bounds are a list of 4 items: can't remember the order but like top, left, bottom, right. In the previous versions (of Quark? or of the system?) those values used to be "human readable" numbers and it was quite easy to interact with. Then came some data values harder to deal with in math operations, hence the coercion to numbers*.
In the current related case the values seem to be yet different. I do own a copy of Quark 2017 but don't really have time to play with it now. I'll try to dig deeper ASAIC. Unless someone comes up with a solution in the meantime.

* In QXP9, results look like this:
set the_bounds to bounds of current box
--> «data FRMSB2DB35005DB138008B22C10032AECF00»

set my_list to bounds of current box as list
--> {«data FXVMB2DB3500», «data FXHM5DB13800», «data FXVM8B22C100», «data FXHM32AECF00»}

set x1 to item 1 of my_list
--> «data FXVMB2DB3500»

set coerced_x1 to (coerce item 1 of my_list to number)
--> 19

Offline

 

#6 2019-05-14 01:59:14 am

CMYS
Member
From:: Belgium
Registered: 2007-07-02
Posts: 86

Re: Script worked on Quark 9.5 and not working in Quark 2017

johnmathew wrote:

Hi,

What is the number of "p"?



It is the Picas Measurement in Quark (like Millimeter, Inches etc.,)

Without Coercing, the script doesn't work in Older version.


Thanks



Oh I think KniazidisR meant that letter "p" appearing in the result just can't be coerced to any number. Whatever its meaning in the application. Are you with me?

Offline

 

#7 2019-05-15 01:00:38 am

johnmathew
Member
Registered: 2009-10-12
Posts: 94

Re: Script worked on Quark 9.5 and not working in Quark 2017

Hi,

Applescript:

get horizontal offset of text from character 460 to character 465 of story 1 of text box 1 of document "Project1.qxp"
--> "4p4.687"
get width of text from character 460 to character 465 of story 1 of text box 1 of document "Project1.qxp"
--> "2p6.012"
coerce {"4p4.687"} to real
--> error number -1700

Can we convert like this (horizontal offset).
i.e., 4p4.687
item 1 - "4" (Before p) (4p is 4 Picas) (1 Pica = 12 points) So 4 multiply by 12 - Result = 48
item 2 - "4" (After p and upto ".") 48 Plus 4 - Result = 52
item 3 - 687 (After ".") 52 & 687 - Result = 52.687

(Width of text)
i.e., 2p6.012
item 1 - "2" (Before p) (2p is 2 Picas) (1 Picas = 12 points) So 2 multiply by 12 - Result = 24
item 2 - "6" (After p and upto ".") 24 Plus 4 - Result = 28
item 3 - 012 (After ".") 28 & 012 - Result = 28.012

Thanks

Offline

 

#8 2019-05-15 03:00:31 am

CMYS
Member
From:: Belgium
Registered: 2007-07-02
Posts: 86

Re: Script worked on Quark 9.5 and not working in Quark 2017

Thinking of that couldn't you try to convert the default measure units to say millimeters prior to work on your measures so that you'd get rid of the "p" issue. Are you with me? I can see horizontal and vertical measure (get/set; horizontal measurement units) are properties of the layout space, so be set at that level. HTH.

You'll also probably want to somehow round the values you get (on a test I just made for sth different, I got 30.000061035156 instead of 30).

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)