Re: Changing case to lower case in QuarkXPress v5
Re: Changing case to lower case in QuarkXPress v5
- Subject: Re: Changing case to lower case in QuarkXPress v5
- From: Arthur Knapp <email@hidden>
- Date: Mon, 27 Oct 2003 10:26:15 -0500
Date: Sun, 26 Oct 2003 21:54:49 -0500
Subject: Changing case to lower case in QuarkXPress v5
From: "Bob.Kalbaugh" <email@hidden>
I've been working on a script for QuarkXPress v5 that gets the
contents of
selected text from a document, runs it through a handler to change the
case
and then changes the selection to the revised text. It worked fine
but, if
any of the text in the selection was styled it got lost in translation.
(contents of selection returns plain text.)
I have an old script that does the same thing.
However, it is slow and clunky.
Mine too, but see below:
on lowCase(x)
...
set nTxt to nTxt & (character (offset of i in uChars) of
lChars)
One of you biggest slow downs here is the "offset of" command. When
used
for each character of a long string, it can really slow things down.
Here is my solution, circa the year 2000 or so:
tell application "QuarkXPress" to activate
set kUpper to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set kLower to "abcdefghijklmnopqrstuvwxyz"
tell application "QuarkXPress" to set theText to contents of selection
repeat with x from 1 to 26
if theText contains kUpper's item x then
set text item delimiters to kUpper's item x
set theText to theText's text items
set text item delimiters to kLower's item x
set theText to "" & theText
end if
end repeat
-- Have to keep style, character by character
--
tell application "QuarkXPress"
repeat with x from length of theText to 1 by -1
if character x of theText is not return then
ignoring application responses
set character x of selection to character x of theText
end ignoring
end if
end repeat
end tell
If I were going to re-write this today, I would probably adopt your
method of working with each style run, but under no circumstances
would I use "offset of" for each character, I know from experience
that text item delimiter soulutions will almost always be faster,
(though I can't speak for Panther, as I have't given it a shot yet). :)
{ Arthur J. Knapp;
<
mailto:email@hidden>;
What...? Oh...!
}
_______________________________________________
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.