Re: Write to file
Re: Write to file
- Subject: Re: Write to file
- From: Andrew Oliver <email@hidden>
- Date: Sat, 20 Dec 2003 23:34:48 -0800
Sure, except that your syntax requires the file already exist - it won't
create the file for you.
To overcome that, you can use the 'open for access' command which will
create the file if it doesn't already exist:
set outputFile to open for access "Macintosh
HD:Users:johnfowler:Desktop:mytextfile.txt" with write permission
set eof outputFile to 0 -- reset the file contents if needed
write "this text" to outputFile -- no need to track the byte count unless
you want to
close access outputFile -- just be sure you close the file when done
Also, to be safer, you can use the 'path to desktop' rather than the full
pathname - that way your script will continue to work if you change disks or
username:
set outputFile to open for access (path to desktop as text) &
"mytextfile.txt" with write permission
Andrew
:)
On 12/20/03 10:33 PM, "John Fowler" <email@hidden> 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.