Character width of selected text.

Hi Guys,

I am using Quark Xpress 8.

How can i know the exact character width of the selected text using applescript?

If any one helps it will be more helpful.

Thanks,
John

It has been a while since I have scripted Quark but looking at some documentation characters have both a horizontal offset and a width property.

Ideally the width property will give you what you need. The only problem is that based on the PDF I was able to pull up from Quark’s site it looks like it only returns the width of the first character.

The horizontal offset might be another way if it is returning a useful value and not just an index of the position on the line of text (ie character 2 of line 2). I have used a similar property in InDesign to get the width of a range of characters by getting the end horizontal offset of the last insertion point of the last character of the selection and subtracting the horizontal offset of the first insertion point of the first character.

What I would do is set a variable to these properties and look at what is returned. Not sure of the exact syntax but if you have one character selected you should be able to do something like:


tell application "Quark"
    set theSelection to seleciton
    set values to {horizontal offset of of theSelection, width of theSelection}
end tell

look at the “results” window in script editor to see if it is returning what you need.

Hi Jerome,

I have tried it. Applescript shows the following error in result.

error “The variable seleciton is not defined.” number -2753 from “seleciton”

Thanks,

Just a quick observation, there’s a spelling mistake on the 2nd line.

Change it to:-

set theSelection to selection

Hi TecNik,

After the changes, if I run the script my quark was quitted.

tell application "QuarkXPress"
	set theSelection to selection
	set values to {horizontal offset of theSelection, width of theSelection}
end tell

Thanks,
Mathew

G’day

I don’t use quark so cant test, but this information may be of use

http://forums.quark.com/p/28049/112185.aspx

Hi John

I guess that it would be fine to edit

tell application “QuarkXPress”
into
tell application “QuarkXPress” to tell document 1

Yvan KOENIG (VALLAURIS, France) mercredi 11 avril 2012 10:15:11

Hi,

Oops… Still quark has quit after changing the script as follows:


tell application "QuarkXPress" to tell document 1
	set theSelection to selection
	set values to {horizontal offset of theSelection, width of theSelection}
end tell

Thanks,
John