2 Replies Latest reply on Nov 11, 2008 2:43 PM by Roy McCoy

    Single line find/change command?

    Roy McCoy Level 1
      I have to create a complex find/change AppleScript script with hundreds of text conversions, for which the following syntax seems bulky and awkward, at least in contrast to earlier scripting languages:

      set find what of find text preferences to "c`"
      set change to of change text preferences to "ĉ"
      change text

      Does anyone know of a way to get this on a single line?

      Thanks,
      Roy McCoy
        • 1. Re: Single line find/change command?
          sstanleyau Level 4
          On 12/11/08 8:33 AM, "Roy McCoy" <member@adobeforums.com> wrote:<br /><br />> Does anyone know of a way to get this on a single line?<br /><br />You can't. You can do it in two:<br /><br />set properties to {find text preferences:{find what:"c`"}, change text<br />preferences:{change to:"Ä"}}<br /><br />But really, why bother? If you have hundreds of them, put it in a loop:<br /><br />set theFinds to {"c`",...}<br />set theChangess to {"Ä",...}<br />repeat with i from 1 to count of theFinds<br />set find what of find text preferences to (item i of theFinds)<br />set change to of change text preferences to (item i of theChanges)<br />change text document 1<br />end repeat<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
          • 2. Re: Single line find/change command?
            Roy McCoy Level 1
            Shane Stanley wrote:

            >> Does anyone know of a way to get this on a single line?
            >
            > You can't.

            Okay, now I know, thanks.

            > You can do it in two:
            >
            > set properties to {find text preferences:{find what:"c`"}, change text
            > preferences:{change to:"Ä"}}
            >
            > But really, why bother?

            Because I think that's going to be easier to edit and possibly less
            prone to error than with long, comma-delineated lists of find and
            change terms.

            > If you have hundreds of them, put it in a loop:
            >
            > set theFinds to {"c`",...}
            > set theChangess to {"Ä",...}
            > repeat with i from 1 to count of theFinds
            > set find what of find text preferences to (item i of theFinds)
            > set change to of change text preferences to (item i of theChanges)
            > change text document 1
            > end repeat

            That's certainly elegant, thanks. I'll probably use it for some
            routines - ironically, the shorter ones for which I don't need a more
            concise format so much.


            Roy McCoy