Problems Writing to a File
Problems Writing to a File
- Subject: Problems Writing to a File
- From: Steve Suranie <email@hidden>
- Date: Thu, 10 Nov 2005 13:20:24 -0500
- Thread-topic: Problems Writing to a File
I'm trying to write to a file but I am having some problems with my script:
If I use this script it works fine:
set theFilePath to "Macintosh
HD:Users:steve:Desktop:archiveTool:htmlFiles:tempFile.txt" as string
set theContent to "This is a test"
my writeFile(theFilePath, theContent)
--subs--
on writeFile(theFilePath, theContent)
tell application "Finder"
set f to (open for access theFilePath with write permission)
write theContent to f
close access f
end tell
end writeFile
but I want to be able to use this script on any desktop. I can control the
folder hierarchy from "archiveTool" on down, it's the path to the desktop
which will be dynamic.
So I changed the script to this:
set theFilePath to (path to desktop) & "archiveTool:htmlFiles:tempFile.txt"
as string
set theContent to "This is a test"
my writeFile(theFilePath, theContent)
--subs--
on writeFile(theFilePath, theContent)
tell application "Finder"
set f to (open for access theFilePath with write permission)
write theContent to f
close access f
end tell
end writeFile
I get an error message in the subroutine telling me the Finder cannot find
the file. I've tried open for access file theFilePath, open for access alias
theFilePath, wrapping it in a tell application "Finder" call and I still get
the same error.
When I return the path to desktop I get what I have been hard coding:
Macintosh HD:Users:steve:Desktop:
Can anyone explain what I am doing wrong?
Gracias
Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden