• 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: Write to file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Write to file


  • Subject: Re: Write to file
  • From: Graff <email@hidden>
  • Date: Sun, 21 Dec 2003 02:29:58 -0500

You need to open the file with write permission. You should also close it after you are done. It is also a good practice to put all this in a try block so that you can make sure that no matter what happens the file is closed:
-------------
set theFile to (path to desktop as text) & "mytextfile.txt"
try
set openedFile to open for access theFile with write permission
write "this text" to openedFile
close access openedFile
on error
if openedFile is not "" then
close access openedFile
end if
end try
-------------

- Ken

On Dec 21, 2003, at 1:33 AM, John Fowler wrote:

I am a little confused about whether it is still possible to use syntax
such as this to write data to a file:

write "this text" to file "Macintosh
HD:Users:johnfowler:Desktop:mytextfile.txt" starting at 0 for 9

Is there a scripting addition compatible with Panther that responds to
this? Short of using an app such as bbedit to create and save a
document, is there a way within AppleScript to create a file and fill
it with text data?

Thanks.

John Fowler
_______________________________________________
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.
_______________________________________________
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:
    • checking if variable is defined
      • From: Graff <email@hidden>
References: 
 >Write to file (From: John Fowler <email@hidden>)

  • Prev by Date: Re: Sorting IP addresses
  • Next by Date: Re: Write to file
  • Previous by thread: Write to file
  • Next by thread: checking if variable is defined
  • Index(es):
    • Date
    • Thread