On 28 Jan 2013, at 5:47 PM, Christopher Stone wrote: Close access not necessary, because you've never opened a file for access to begin with.
Not for write access, no, but I thought I did open it for reading with the " set booksList to read sourceFile" command. Or does that automatically close the file after the reading is done? read alias ((path to documents folder as text) & "BUUF:BUUF Library:BUUF library in OO.txt") as «class utf8»
The data file has some accented letters (such as "Mészkö"), which is why I used the " as Unicode text" clause. Does class "utf8" cover that?
This will produce an -39 error on my machine if the file has NO content.
The source file has around 1500 lines of data--definitely not empty. Something like this might work for you:
When I tried that, without changing anything, the "read alias" command yielded:
display dialog "End of file error.
Num: -39" with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK" --> {button returned:"OK"}
Somehow, it is getting to the file but not into it. I wish I had some way of breaking down the initial "read" to see what it is seeing or not seeing, but all I have is the "Replies" output of AppleScript Editor. I guess I'd need byte-by-byte machine code for that. You don't need to read with a delimiter unless it is neither CR or LF.
Using choose file to do this piecemeal seems mighty inefficient. Are you doing this for testing, or is this genuinely a necessary part of your workflow?
I put that in because I was having trouble with the read..alias business, but ultimately it will be a good thing, so the input or output can exist anywhere. It also averts any problem with me mispunctuating or misspellilng the file path, because I'm selecting actual files. If you give us a little more information we might be able to help streamline things a bit.
Thank you. More background: the data file is generated from a database, as tab-delimited text. A typical line is:
Hurff, Matthew The Millenium Time Tapestry Pindar 1999 Art
The purpose of this program is to turn the text file into a column-sortable HTML file, like the one at http://www.boiseuu.org/LibraryDB/index.html . It is also a learning experience; I have tinkered with AppleScripts for years, but never using file I/O.
BTW, if it matters, my MacBook Pro is running Snow Leopard (v. 10.6.8).
-*"*-.,,.-*"*-.,,.-*"*-.,,.-*"*-.,,.-*"*-.,,.-*"*-.,,.-*"*— Ed Rush, Boise, Idaho email@hidden
|