Re: QuarkXPress: finding anchored boxes
Re: QuarkXPress: finding anchored boxes
- Subject: Re: QuarkXPress: finding anchored boxes
- From: Hans Haesler <email@hidden>
- Date: Tue, 20 Mar 2001 11:01:48 +0100
On Mon, 19 Mar 2001, Michael Turner wrote:
>
How would you do the opposite? Find a nested text box, presuming you do not
>
know the position? Would naming all the anchored text boxes help? How?
Hello Michael,
no, it wouldn't help, because you want address the selection.
>
(...) Is there a test for selections (in contents mode) to
>
"have" or "not have" anchored boxes?
If you need to know the _exact_ number of the anchored boxes then you
could use the idea of your PSEUDOcode. Just be aware that you must create
a text box at the new document before pasting the selection.
Here is another solution.
Every anchored box can be detected because of it's three invisible
characters. The first one is always ASCII 4, the second one may be
ASCII 0 or ASCII 1, the third can be every number from 1 to 255.
Select just the range of (the character before the box, the box itself and
the character after the box) and run this:
---
set codeList to {}
tell document 1 of application "QuarkXPress 4.11"
tell selection
repeat with i from 1 to count of characters
set actChar to character i
set ascCode to (ASCII number of actChar)
set end of codeList to ascCode
end repeat
end tell
end tell
codeList
---
The result should be something like: {115, 4, 0, 1, 109}
Now, the idea is to count the occurrences of ASCII character 4 in the
selection, using the text item delimiters:
---
tell document 1 of application "QuarkXPress 4.11"
activate
set oD to AppleScript's text item delimiters
set aSel to text of selection
set AppleScript's text item delimiters to {ASCII character 4}
set numBox to (count text item of aSel) - 1
set AppleScript's text item delimiters to oD
if numBox = 0 then
display dialog "The selection doesn't contain any anchored box."
else if numBox = 1 then
display dialog "The selection contains 1 anchored box."
else if numBox is greater than 1 then
display dialog "The selection contains anchored boxes."
end if
end tell
---
If the variable numBox is greater than 1 then we could use it in the
dialog, BUT the number wouldn't be reliable: {4, 0, 4} is one box but
would be counted as two boxes. The same applies if your selection contains
only one box, and it's code is {4, 0, 4}.
Regards,
Hans
---
Hans Haesler | email@hidden