Re: Quark
Re: Quark
- Subject: Re: Quark
- From: Hans Haesler <email@hidden>
- Date: Wed, 1 Aug 2001 23:36:13 +0200
On Wed, 1 Aug 2001, Andrew McNichol wrote:
>
Hello, I am new to applescript (os8.5) & scripting quark (4.11)
Hello Andrew,
welcome aboard :-)
>
I am trying to set the name of every box selected into a list to
>
manipulate in a loop later.
>
here's what I have to far...
>
>
tell application "QuarkXPress"
>
activate
>
tell current page of document 1
>
set BoxSelected to (name of (every picture box of
>
document 1 whose selected)) as list
>
end tell
>
end tell
Five remarks:
1) There is a 'of document 1' inside of a 'document 1 block'
(you don't need to repeat 'of document 1')
2) ... whose selected ... is what? ... An 'is true' is missing.
3) You don't need to specify 'as list', else each name will be
a list within a list, i.e. {{"test1"}, {"test2"}, {"test3"}}
instead of {"test1", "test2", "test3"}.
4) The 'whose' clause returns false results when the selected
boxes are on one of two (or more) pages of the same spread.
And it doesn't help to say:
---
set BoxSelected to (name of (every picture box of current page ...
---
5) Be careful with 'current page'. This is mostly not the page
which the user is looking at...
I think you'll be better off with a slower (but more accurate)
repeat loop. The list variable is initialized, at the beginning,
as an empty list: 'set BoxSelected to {}'. Then the script loops
through the boxes of the page. Here we use 'generic', so every
kind of box type is covered.
The variable 'i' is commonly used as counter variable.
Its start value (in the following snippet) is '1' and it is
automatically incremented by 1 until the end value (the number
of all boxes on the corresponding page) is reached.
If the box is selected then the name is added to the end of the
list. This is faster than making a copy of the list and concatenate
the new name (set BoxSelected to BoxSelected & BoxName).
---
tell document 1 of application "QuarkXPress 4.11"
activate
set BoxSelected to {}
tell current page
repeat with i from 1 to count generic boxes
tell generic box i
if selected is true then set end of BoxSelected to name
end tell
end repeat
end tell
BoxSelected
end tell
---
The 'BoxSelected' at the end makes sure that the whole list is
visible in the result window. Else you'll see only the last item.
Best regards,
Hans
---
Hans Haesler <email@hidden>
References: | |
| >Quark (From: Andrew McNichol <email@hidden>) |