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: Matt Neuburg <email@hidden>
- Date: Mon, 24 Apr 2006 10:23:02 -0700
- Thread-topic: problem writing out XML suite parsed file to disk
> Date: Thu, 20 Apr 2006 16:16:38 +0100
> From: email@hidden
> Subject: problem writing out XML suite parsed file to disk
>
> I am having problems writing out the contents of an XML file that has
> been parsed in using XML suite to a new file. Using a test app, shown
> below, I consistently get the error message:
>
> An error was encountered writing the file to: "my file path". Error:
> System Events got an error: File some object wasn't open.
>
> The test app code is shown below:
>
> ------------------------------------------
> set thePodcast to ""
> set xmlFile to "/Path/To/XMLFILE/file1.xml"
> tell application "System Events"
> set thePodcast to (contents of XML file xmlFile)
> end tell
>
> set posixPath to "/Path/To/XMLFILE/file2.xml"
> set file_path to POSIX file posixPath
>
> try
> set open_file to open for access file_path with write permission
> set eof of the open_file to 0
> write thePodcast to open_file starting at eof
> close access file file_path
The word "file" in that last line is a bug. You've confused yourself by
calling your variable "file_path". It is not a path; it is a POSIX file. It
is already a way of specifying the file, so you cannot use it form an a file
specifier with the word "file". Notice the mismatch between how you specify
the file in the "open for access" and how you do it in the last line. Of
course the real solution is to close access open_file - once you have a file
number, just keep using it. Basically you've used so many ways of referring
to the file that you've confused the heck out of yourself. m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119
Take Control of Word 2004, Tiger, and more -
http://www.takecontrolbooks.com/tiger-customizing.html
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
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