• 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: Simple AS question (BBEdit)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple AS question (BBEdit)


  • Subject: Re: Simple AS question (BBEdit)
  • From: "Nigel Garvey" <email@hidden>
  • Date: Thu, 5 Feb 2009 23:08:47 +0000

Chris Goedde wrote on Thu, 5 Feb 2009 13:20:46 -0600:

>I appreciate the two responses so far, but they don't quite address
>the issue I'm concerned about. I realize that I can work with the text
>of the document; what I'm more worried about is the reference to the
>document itself. Here's a slight variation of my original script:
>
>set thePath to (path to desktop as string)
>set theOffset to offset of "Desktop" in thePath
>set thePath to (text 1 through (theOffset - 1) of thePath)
>set thePath to thePath & "Documents:Work:Professional:STEP:Web
>Site:Development:"
>
>tell application "BBEdit"
>
>	set indexFile to thePath & "index.html"
>	open indexFile
>	set indexDoc to text document "index.html"
>
>	set indexText1 to text of indexDoc
>
>	set footerFile to thePath & "footer.shtml"
>	open footerFile
>
>	set indexText2 to text of indexDoc
>
>end tell

If BBEdit is like TextWrangler, it returns index references when you set
indexDoc and (in your original post) footerDoc. Since each of these
documents is frontmost when the relevant variable is set, the document
index is the same in both cases (1) and therefore so is the reference.
You need to use a name reference to differentiate between them (as Eric
suggested), which can only be done by using a name specifier, not by
assigning the document to a variable.

  set indexText to text of document "index.html"

'open' returns a reference to the just-opened document, so you could get
the text directly from the result:

  set thePath to (path to documents folder as text) &
"Work:Professional:STEP:Web Site:Development:"

  tell application "BBEdit"

    set indexText to text of (open file (thePath & "index.html"))
    set footerText to text of (open file (thePath & "footer.shtml"))

    -- Blah blah

    set text of document "index.html" to editedIndexText
    set text of document "footer.shtml" to editedFooterText
  end tell


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: Quark Annotate script problem with Leopard
  • Next by Date: Re: Filemaker Script
  • Previous by thread: Re: Simple AS question (BBEdit)
  • Next by thread: Re: Finding and shelling out to a sh script in the same directory as the AppleScript
  • Index(es):
    • Date
    • Thread