Re: problem writing out XML suite parsed file to disk
Re: problem writing out XML suite parsed file to disk
- Subject: Re: problem writing out XML suite parsed file to disk
- From: "J. Stewart" <email@hidden>
- Date: Tue, 25 Apr 2006 04:40:02 -0400
On 4/25/06 at +0100 email@hidden said this
>try
> set the open_file to open for access file_pointer with write permission
> set eof of the open_file to 0
> tell application "System Events"
> write text of thePodcast to open_file starting at eof
> end tell
>
> display dialog "Written the file"
>
> close access open_file
>........
>end try
>
>I never reach the 'Written the file' dialogue - instead I get the
>"System Events got an error: File some object wasn't open." message.
There's a couple of things that stand out.
Why is the write command within a System Events tell? It's from the Standard Additions osax and has nothing to do with System Events.
The try block will not close the file if it throws an error. You've left out the "on error" portion so the block just ignores any errors. This is fine if you don't need to handle errors but in this case you do!
This script is written with the assumption that "thePodcast" is textual in nature and not audio or video.
--> Script <--
set fPath to "the:path:to:your:file" as Unicode text
try
set fRef to open for access file fPath with write permission
set eof fRef to 0 -- not necessary if new file
write thePodcast to fRef as text starting at 0
close access fRef
on error errMsg number errNum
close access file fPath
display alert ("Error # " & errNum) message errMsg buttons {"Cancel"} giving up after 5
-- your error handler code goes here
end try
--> /Script <--
JBS
--
I don't know how I got over the hill without getting to the top. — Will Rogers
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden