Changing case to lower case in QuarkXPress v5
Changing case to lower case in QuarkXPress v5
- Subject: Changing case to lower case in QuarkXPress v5
- From: "Bob.Kalbaugh" <email@hidden>
- Date: Sun, 26 Oct 2003 21:54:49 -0500
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 altered the script to loop through every text style range of the selection
instead, and it works as expected. However, it is slow and clunky.
The script in its current, rough form follows. I'm aware that the handler is
not very efficient, which contributes to the slowness of it. It needs to be
optimized (I'm just testing right now.) Looping through the text style range
is not my idea of how to handle it either. I just can't think of any other
way to do it.
Is there a way to get all of the text of the selection, revise it without
blasting the style and return it to the selection?
--Script --
property uChars : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
property lChars : "abcdefghijklmnopqrstuvwxyz"
tell application "QuarkXPress"
set sTxt to (get selection)
set cTSR to (count text style range of sTxt)
repeat with i from 1 to cTSR
set tsr to text style range i of sTxt
set tsr to my lowCase(tsr)
set text style range i of sTxt to tsr
end repeat
select sTxt
do updates
end tell
on lowCase(x)
set nTxt to ""
considering case
repeat with i in x
if i is in uChars then
set nTxt to nTxt & (character (offset of i in uChars) of lChars)
else
set nTxt to nTxt & i
end if
end repeat
end considering
return nTxt
end lowCase
-- End Script --
Thanks.
--
Bob.Kalbaugh
_______________________________________________
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.