Re: Writing To A File
Re: Writing To A File
- Subject: Re: Writing To A File
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 29 Sep 2003 18:45:25 -0700
On 9/29/03 2:49 PM, "Steve Mills" <email@hidden> wrote:
>
On Monday, Sep 29, 2003, at 16:25 US/Central, Walter Ian Kaye wrote:
>
>
> It's probably your file reference. Starting with ":Users" is not
>
> likely to do what you want. Here's something more reliable:
>
>
Heh, I didn't even catch that. When my brain saw that somebody was
>
having problems with "open for access", I automatically assume the
>
problem is one of the many inherent with those commands. Oh well. :)
>
And why did you put your file access commands inside a Finder tell block in
the first place? Just as a demonstration, I guess. You're right that
different apps have their own reference numbers. I find it's best to call
out to a handler if I need to access file references from within tell
blocks:
set refNum to (open for access file "disk:file" with write permission)
--!! note you need 'file' or 'alias'
tell app "Finder"
--stuff
my WriteToFile("some text", refNum )
end tell
tell app "TextEdit"
--stuff
my WriteToFile("blah", refNum )
end tell
try
close access refNum
end try
on WriteToFile(r, refNum )
try
write (r & return) to refNum
on error
try
close access refNum
end try
display dialog "Some problem with writing to file."
error number -128 -- or whatever
end try
end WriteToFile
--
Paul Berkowitz
_______________________________________________
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.