Re: can't make document
Re: can't make document
- Subject: Re: can't make document
- From: Walter Ian Kaye <email@hidden>
- Date: Mon, 23 Feb 2004 18:06:15 -0800
At 08:21p -0500 02/23/2004, Wesley Smith didst inscribe upon an
electronic papyrus:
Here's the code form the script that I'm using to read the text file:
-----------------------------
tell application "Finder"
set Media_Hole to disk "Media Black Hole"
set Pavilion to folder "pavilion" of Media_Hole
exists file "listing.txt" of folder "Pavilion" of disk "Media Black Hole"
set listing to file "listing.txt" of folder "Pavilion" of disk
"Media Black Hole"
get properties of listing
open for access file "listing.txt" of folder "Pavilion" of disk
"Media Black Hole"
get eof of result
end tell
------------------------------
If I replace the third to last line with:
open for access listing or
open for access file listing
I get the error cannot make file Media Black Hole:Pavilion:listing.txt.
The way it is up above gives and eof result of 0.0 which means an
empty file. This is definitely not the case.
Does anyone know what I'm doing wrong?
Finder is co-opting the 'file' keyword because you are trying to pass
a Finder object (file x of folder y of disk z) to a command ('open
for access') which knows *nothing* about Finder objects. I don't know
why Mr Tea thinks that alias won't work, because it should (maybe he
mis-counted his list).
Also, I don't know why you are doing an 'exists' without using the
result in an 'if' statement, or several other lines there whose
results are not being used.
In any case, try this:
set listing to "Media Black Hole:pavilion:listing.txt"
tell application "Finder" to set gotFile to exists alias listing
if gotFile then
set fref to open for access alias listing
set flen to get eof of fref
close access fref
display dialog listing & " has a length of " & flen else
else
display dialog listing & " does not exist."
end if
Note that here, Finder is only being used to test the existence of the file.
Also note that we're closing the file after we're done with it.
-boo
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.