• 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: Scripting RagTime
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting RagTime


  • Subject: Re: Scripting RagTime
  • From: "Nigel Garvey" <email@hidden>
  • Date: Fri, 23 Mar 2007 02:31:58 +0000

Benedikt Quirmbach wrote on Thu, 22 Mar 2007 10:25:07 +0100:

>is there anyone out there who works with RagTime?
>
>If yes, did you ever script search & replace in RagTime?
>Do you have an example on how to do that?

I have RagTime Solo (5.6.4), but only use the spreadsheet. Because of its
complexity and eccentricities, it's not a particularly friendly
application to script. The handler below only works with 'text flow' text
in layout documents, but it may give you somewhere to start.

  on searchAndReplace(searchText, replaceText)
    set searchTextLen to (count searchText)
    set astid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to searchText

    tell application "RagTime Solo"
      tell front document
        repeat with i from 1 to (count each text flow)
          set thisText to (text of text flow i) as string as Unicode text
          if (thisText contains searchText) then
            -- Replace the individual search-text occurrences
            -- in the document itself, to preserve style info.
            set b to (count thisText)
            set textItems to reverse of rest of thisText's text items
            repeat with thisTextItem in textItems
              set b to b - (count thisTextItem)
              set a to b - searchTextLen + 1
              set text a thru b of text flow i to replaceText
              set b to a - 1
            end repeat
          end if
        end repeat
      end tell
    end tell

    set AppleScript's text item delimiters to astid
  end searchAndReplace

  searchAndReplace("Fred", "Aardvark")


NG

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Open for access with write permission
  • Next by Date: Re: last opened
  • Previous by thread: Scripting RagTime
  • Next by thread: iTunes, NSAppleScript, and timeout
  • Index(es):
    • Date
    • Thread