Re: Dialects
Re: Dialects
- Subject: Re: Dialects
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 13 Nov 2000 09:27:25 -0800
On 11/13/00 5:55 AM, "Xandra Lee" <email@hidden> wrote:
>
I had a one line script which worked fine in Tex-Edit until about version
>
4.
>
It was designed to makes every blank paragraphs 4 points.
>
>
Orig Script
>
tell document 1 of application "Tex-Edit Plus"
>
set size of character 1 of (every paragraph whose length = 0) to 4
>
end tell
>
>
Beginning about Version 4, above script stopped fuctioning (no errors -
>
just no results)
>
It appears that the problem stems from the fact that the first script's
>
"whose clause" now returns contents rather than a reference to the
>
paragraph number. ie line 2 -> {"", "",...}.
That's _not_ the reason, Xandra. You can check. Pick some paragraph whose
length you know:
tell app Tex-Edit Plus
tell document 1
set ln to length of paragraph 1
set size of character 1 of (every paragraph whose length = ln) to 9
end tell
end tell
Watch what happens! There's no problem with the whose clause.
What they've done in TE+ is regularize the fact that a paragraph whose
length is 0 does not _have_ a character 1, does it? So when you set the size
of character 1 of any paragraph whose length is 0, nothing happens. That's
actually more accurate than the shorthand you had before, which was sort of
a hack, I guess.
In your repeat loop below, check to see what the character actually is whose
size you're reducing. You'll find that character 1107 of document 1 is not
"" . It's
"
"
It's the return character. But the return character doesn't "count" in
paragraphs. The blank line doesn't get a paragraph index number at all. But
it does get a _line_ index number. What you're really looking for is:
tell document 1
set size of character 1 of (every line whose contents = return) to 4
end tell
>
I've only been able to replace it with the MUCH slower version since it
>
requires a repeat clause. as follows..
>
>
tell document 1 of application "Tex-Edit Plus"
>
set x to (offset of every paragraph whose length = 0)
>
-->{1107, 2129, 2260,...}
>
repeat with i from 1 to (count of items of x)
>
set size of character (item i of x) to 4
>
end repeat
>
end tell
BTW, when you do have to use a repeat loop with many items, it's faster if
you set a variable to the (count of items of x), so it doesn't have to be
recalculated on every loop.
>
>
>
Any ideas on syntax that would NOT require a repeat.
>
Above.
--
Paul Berkowitz