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

Opening and reading a text file


  • Subject: Opening and reading a text file
  • From: Ed Rush <email@hidden>
  • Date: Mon, 28 Jan 2013 15:41:03 -0700

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:

read alias "Goalie:Users:edr:Documents:BUUF:BUUF Library:BUUF library in OO.txt" as Unicode text using delimiter "
"
--> error number -10004
end tell
tell current application
read alias "Goalie:Users:edr:Documents:BUUF:BUUF Library:BUUF library in OO.txt" as Unicode text using delimiter "
"

Result:

error "TextWrangler got an error: End of file error." number -39 from file "Goalie:Users:edr:Documents:BUUF:BUUF Library:BUUF library in OO.txt"


I found that error -10004 is a permissions error, so I made sure that the files and their folders are all "Read & Write," but the problem persists. Error 39 is the EOF, presumably resulting from inability to open the file.

 
-*"*-.,,.-*"*-.,,.-*"*-.,,.-*"*-.,,.-*"*-.,,.-*"*-.,,.-*"*—
Ed Rush, Boise, Idaho

email@hidden




 _______________________________________________
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>
    • Re: Opening and reading a text file
      • From: Thomas Fischer <email@hidden>
    • Re: Opening and reading a text file
      • From: Christopher Stone <email@hidden>
  • Prev by Date: Re: Searching for scripts - One solution
  • Next by Date: Re: Opening and reading a text file
  • Previous by thread: Re: Searching for scripts - One solution
  • Next by thread: Re: Opening and reading a text file
  • Index(es):
    • Date
    • Thread