• 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: Opening and reading a text file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opening and reading a text file


  • Subject: Re: Opening and reading a text file
  • From: "koenig.yvan" <email@hidden>
  • Date: Tue, 29 Jan 2013 15:14:35 +0100


Le 28/01/2013 à 23:41, Ed Rush <email@hidden> a écrit :

I'm trying to open an existing text file, add some HTML code, and write the result to replace a pre-existing second file, but I keep getting an end-of-file error right off the bat:

tell application "TextWrangler"
activate

set sourceFile to (choose file with prompt "Choose the ... text file:")
set targetFile to (choose file with prompt "Choose the ... HTML file:")

set introText to "<!DOCTYPE html PUBLIC ...(lots of header code)"


--read the books list 
set booksList to read sourceFile as Unicode text using delimiter return
close access sourceFile

... <loop to do the deed, etc.>
end tell --"TextWrangler"


I'm trying to open an existing text file, add some HTML code, and write the result to replace a pre-existing second file. I've tried it with the surrounding "tell" set to TextEdit, TextWrangler, Finder, and nothing. Regardless, I get this:


Hello

As you are using TextWrangler, why not ask it to grab the document's contents ?

This simple code does the job.

(*set sourceFile to (choose file with prompt "Choose the ... text file:")
set targetFile to (choose file with prompt "Choose the ... HTML file:")

set introText to "<!DOCTYPE html PUBLIC ...(lots of header code)"
*)
set sourceFile to (path to desktop as text) & " à ranger:excel filetypes.txt" as alias
tell application "TextWrangler"
# read the books list
open sourceFile
# set booksList to contents of document 1
set booksList to paragraphs of (get contents of document 1)
close document 1
end tell --"TextWrangler"
# <loop to do the deed, etc.>

Yvan KOENIG (VALLAURIS, France) mardi 29 janvier 2013 15:14:06


 _______________________________________________
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

  • Follow-Ups:
    • Re: Opening and reading a text file
      • From: "koenig.yvan" <email@hidden>
References: 
 >Opening and reading a text file (From: Ed Rush <email@hidden>)

  • Prev by Date: Re: Opening and reading a text file
  • Next by Date: Re: Clickable links!
  • Previous by thread: Re: Opening and reading a text file
  • Next by thread: Re: Opening and reading a text file
  • Index(es):
    • Date
    • Thread