Re: Xpress 4.11 - further colour question
Re: Xpress 4.11 - further colour question
- Subject: Re: Xpress 4.11 - further colour question
- From: Hans Haesler <email@hidden>
- Date: Fri, 26 Apr 2002 15:49:26 +0200
On Fri, 26 Apr 2002, email@hidden wrote:
>
prod 1
>
prod 2
>
prod 3
>
prod 4 50% Off
>
Prod 5 50% Off
>
>
I want to change the colour of the "50% Off" bit if it appears. When it
>
does appear, it always appears after the tab and before a return, but may
>
say anything from "10% Off" to "Buy 3 Get 1 Free"
>
>
Basically, what I want to acheive is
>
>
repeat with i from 1 to the number of lines in story 1 of text box 1
>
if tab is in line i of story 1 of text box 1 then
>
set color of words between tab and return of line i of story 1 of text box
>
1 to "Some Colour"
>
end if
>
end repeat
>
>
At the moment, all I've acheived is a long winded loop that checks each
>
character to see if it's between a tab and a return.
>
>
This is because I can't use the standard additions Offset as QXP thinks I
>
mean the Offset property of a text box and complains about "making some
>
data into the expected type".
Steve,
I think this is rather due to a conflict between the offset of a character
in the story and the position of the same character in the paragraph.
These two values are not equal.
When you get the offset of a character then the result is the number
of characters which are before this character, but counted from the
beginning of the story.
In your example, the offset of the character "p" of "prod 4" is '21'.
The offset of the tab in the same paragraph is '27'. But when you count
the characters from the beginning of paragraph 4 then the tab is
'character 7'.
Because you address the range of characters inside of the paragraph,
you must subtract the offset of the tab from the one of the first
character: 27 - 21 = 6. But character 6 is the one _before_ the tab.
I think the color must be applied beginning with the character _after_
the tab. So we must add 2 to the result for the start character or
subtract 2 from the offset of character 1 of the paragraph:
---
tell document 1 of application "QuarkXPress 4.11"
activate
tell current box
repeat with i from 1 to count of paragraphs
tell paragraph i
try
set offOne to (offset of character 1) - 2
set offTab to (offset of every character where it is " ") as list
set color of (characters ((item 1 of offTab) - offOne) thru -1) to "Red"
end try
end tell
end repeat
end tell
end tell
---
The backslash and the "t" of '... where it is "\t")' will disappear when
you check the syntax, but the tab will be there, inside of the quotes.
To speed up the script you may do the usual things: select the Item tool,
hide the Measurements palette, run the script from OSA Menu.
---
Hans Haesler <email@hidden>
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.