• 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
Re: Saving info to a newly created text file from within a script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving info to a newly created text file from within a script


  • Subject: Re: Saving info to a newly created text file from within a script
  • From: kim <email@hidden>
  • Date: Fri, 20 Jul 2001 10:25:50 +1200

G'day david

>2) My first attempts at opening, writing, and closing a file ran into
>errors after the file was opened but before the script closed the file. The
>result was a file sitting there open on my desktop (i.e., unable to open
>again, to delete, or whatever). How do I close this file without restarting
>my Mac?

when writing to a file you really need to enclose it in a try block so if
it errors out, the file closes gracefully.

set thefile to ((path to desktop folder) & "Test file") as text
try
open for access file thefile with write permission
write "the text" to thefile
close access thefile
on error errmess
close access thefile
beep
display dialog "The file could not be written because of error: " &
errmess
end try

cheers

kim


  • Prev by Date: Re: Select CD
  • Next by Date: Re: Unmounting a Server Disk
  • Previous by thread: alert windows
  • Next by thread: AS Problem
  • Index(es):
    • Date
    • Thread