Saving a temp file?
Saving a temp file?
- Subject: Saving a temp file?
- From: James Burns <email@hidden>
- Date: Wed, 12 Feb 2003 14:25:12 -0500
Hello:
Making good progress on my app in AppleScript studio, but have run into
another roadblock. I need to save a temporary file (that I'll alter in
another handler) without any user intervention. I need to overwrite it
if it exists already without bugging the user.
I'm taking a cue from another app and saving the file to
/private/tmp/tempFile, but I get an error if the file already exists.
Here's the relevant handler:
-------------------------------
on changeOutput()
-- write file to temp directory
log "started changeOutput"
set fileContents to read file sceneFile
set AppleScript's text item delimiters to ":"
set sceneName to (last text item of sceneFile as string) -- sceneName
is a var containing a long file name
set AppleScript's text item delimiters to oldDelims
set tempFile to POSIX file ("/private/tmp/" & sceneName) as string --
make new long name log tempFile -- File name seems correctly formatted
here
try
set fileRef to (open for access tempFile with write permission)
set eof of fileRef to 0
write fileContents to fileRef -- right now, just write the file
contents to the temp
close access fileRef
on error what
display dialog what -- kicks here if file exists or other error
close access fileRef
end try
end changeOutput
----------------------------------
I'd appreciate any help in this matter. What I basically have to do is
save a file without confirmation or user intervention, and then it can
be deleted on quitting.
Thanks in advance.
-----
James Burns
http://www.jamesburnsdesign.com
_______________________________________________
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.