Re: can't make document
Re: can't make document
- Subject: Re: can't make document
- From: Michelle Steiner <email@hidden>
- Date: Mon, 23 Feb 2004 18:42:19 -0700
On Feb 23, 2004, at 6:21 PM, Wesley Smith wrote:
tell application "Finder"
set Media_Hole to disk "Media Black Hole"
set Pavilion to folder "pavilion" of Media_Hole
The above lines are meaningless because the variables are never used.
exists file "listing.txt" of folder "Pavilion" of disk "Media Black
Hole"
The above line is meaningless; it returns true or false, but nothing is
done with the result.
set listing to file "listing.txt" of folder "Pavilion" of disk
"Media Black Hole"
get properties of listing
This line will execute regardless of whether the file exists; if it
doesn't exist, there will be an error. if it does exist, the line does
nothing useful.
open for access file "listing.txt" of folder "Pavilion" of disk
"Media Black Hole"
This line will not execute if the file doesn't exist, because the
previous line will result in an error.
get eof of result
end tell
The following script will work; it may not be the best way to do it,
but it works. Note that I changed the name of the disk to my system's
startup disk. I created the pavilion and the file listing.txt on it
for testing purposes.
tell application "Finder"
set Media_Hole to disk "Dora"
set Pavilion to folder "pavilion" of Media_Hole
if exists file "listing.txt" of Pavilion then
set listing to file "listing.txt" of Pavilion as alias
--note that the Finder object must be coerced to an alias because open
for access requires an alias or a file.
end if
end tell
set foo to open for access listing
get eof of foo
--
Never play strip Tarot.
_______________________________________________
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.