Re: looping problem
Re: looping problem
- Subject: Re: looping problem
- From: Hans Haesler <email@hidden>
- Date: Tue, 16 Oct 2001 09:08:53 +0200
On Mon, 15 Oct 2001, Elmer Banate wrote:
>
I need help for may very simple script. I write a
>
script that will delete firts 3 characters of every
>
second line in a text box , those text box are link to
>
each other. (Or IWant to delete every first 3
>
characters in the second paragraph in the text box in
>
a whole document.) Please help.
Elmer,
I ran your script and it worked fine (with my simple test document).
Without seeing your document, I can't tell you why it doesn't work
for you.
I have changed your script a little bit, but there is nothing which
could bring a better result, except -- maybe -- the replacement of
'line 2' with 'paragraph 2'.
---
tell document 1 of application "QuarkXPress 4.11"
activate
set boxList to object reference of every text box whose (name of color of paragraph 2 is "Black")
if class of boxList is not list then set boxList to {boxList}
repeat with aBox in boxList
tell aBox
tell paragraph 2
delete (text from character 1 to character 3)
end tell
end tell
end repeat
end tell
---
I have replaced 'front document' with 'document 1' and inserted it in the
first line. I have deleted the setting of a variable to the name of the
document. I have replaced the counter 'i' with 'aBox' which holds, on
each iteration of the repeat loop, the object reference of the actual box.
This way you avoid to have to count the items of 'boxList' and to have
to set the variable 'aBox' to the items. But this needs to make sure that
'boxList' is a list. That's the reason for the command 'if class of
boxList is not list ...' Else, with only one box, you'd get an error
message when trying to delete the text.
Hans
---
Hans Haesler <email@hidden>