• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Changing case to lower case in QuarkXPress v5
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing case to lower case in QuarkXPress v5


  • Subject: Re: Changing case to lower case in QuarkXPress v5
  • From: Hans Haesler <email@hidden>
  • Date: Wed, 29 Oct 2003 00:42:37 +0100

On Tue, 28 Oct 2003, Arthur Knapp wrote:

>Despite Shane's helping guidance, trying to master Quark scripting is
>not for the faint of heart.... ;-)

Wait until he shows you how to ride a bike! ;-)


>property ksUpper : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
>property ksLower : "abcdefghijklmnopqrstuvwxyz"
>
>tell application "QuarkXPress"
> tell selection
> repeat with i from 1 to 26
> try
> set every character where (it is (get ksUpper's
>character i)) to (get ksLower's character i)
>
> I can't actually test this at the moment, but from what I remember of
>my
>Quark scripting, the "get" statements are needed inside the
>"where/whose"
>statement, and we can use the "try" statement rather than passing an
>AppleEvent asking Quark to test for the presence of "character i" before
>doing something wit it. (I suppose we could also use an "ignoring app
>responses" statement rather than the try-statement.)
>
> This *should* be a very fast solution, but I don't have a Quark handy
>at
>the moment for testing.

Arthur,

the "get" statements are not needed. Tip: replace 'every character'
with 'every text' and it'll be a much faster solution :-)
---
set (every text where it is character i of ksUpper) to character i of ksLower
---
"How much faster?" Well... 140 vs. 600 ticks for 3516 replaced characters.
(Run from Script Editor, QXP 4.11, Mac OS 9.2.2, G4 / 800).

Using the QXP-native 'do script' method: 36 ticks (same conditions).
With 'do script' and run from OSA Menu: 31 ticks.

"Nice... but Bob Kalbaugh (the original poster) uses QXP 5."

There are two problems with version 5:
1) The selection is lost after the first iteration.
2) Execution is _much_ slower: 573 ticks for... 26 characters. No typos.

Workaround for problem #1: use an object reference:
---
tell document 1 of application "QuarkXPress 5.01"
activate
set objRef to object reference of selection
tell objRef
---

Workaround for problem #2: get the contents of the selection and
make the replacement in memory, using, e.g., "RegEx Commands":
---
tell document 1 of application "QuarkXPress 5.01"
activate
set aString to contents of selection
set contents of selection to REReplace aString pattern ".*" with "\\l&"
end tell
---
18 ticks for 3516 replaced characters (run from Script Editor).
Not bad. But, of course, all styling is lost. So we need to loop
through the text style ranges:
---
script upperToLower
tell document 1 of application "QuarkXPress 5.01"
set objRef to object reference of selection
tell objRef
repeat with i from (count of text style ranges) to 1 by -1
set aString to contents of text style range i
set contents of text style range i to REReplace aString pattern ".*" with "\\l&"
end repeat
end tell
end tell
end script

tell application "QuarkXPress 5.01"
activate
do script {upperToLower}
end tell
---
370 ticks for 3516 replaced characters and 15 text style ranges
(run from the QXP Script Menu).

Regards,
Hans

---
Hans Haesler <email@hidden>
_______________________________________________
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.

  • Follow-Ups:
    • Re: Changing case to lower case in QuarkXPress v5
      • From: Shane Stanley <email@hidden>
References: 
 >Re: Changing case to lower case in QuarkXPress v5 (From: Arthur Knapp <email@hidden>)

  • Prev by Date: Re: how do you openurl in safari?
  • Next by Date: iChat
  • Previous by thread: Re: Changing case to lower case in QuarkXPress v5
  • Next by thread: Re: Changing case to lower case in QuarkXPress v5
  • Index(es):
    • Date
    • Thread