• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Saving a temp file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Saving a temp file?
      • From: John Delacour <email@hidden>
  • Prev by Date: Re: Non Compulsory Parameters & a Null Constant ?
  • Next by Date: Re: FM inserting Movie
  • Previous by thread: Arrangement of display 1 & 2
  • Next by thread: Re: Saving a temp file?
  • Index(es):
    • Date
    • Thread