• 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: problem writing out XML suite parsed file to disk
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem writing out XML suite parsed file to disk


  • Subject: Re: problem writing out XML suite parsed file to disk
  • From: email@hidden
  • Date: Tue, 25 Apr 2006 08:16:20 +0100


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,

thanks for the pointers to clean up my code 'chaff' but unfortunately it is not the solution. If I do the following:
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.

I am wondering if the file thePodcast is read from is the closed file object that is being referred to, but opening that before attempting to write to the open_file doesn't make any difference...

cheers

Will



 _______________________________________________
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

  • Follow-Ups:
    • Re: problem writing out XML suite parsed file to disk
      • From: "J. Stewart" <email@hidden>
  • Prev by Date: [ANN] XSpell 3.0
  • Next by Date: Re: Swap keyboard from "belgium" layout to US
  • Previous by thread: Re: problem writing out XML suite parsed file to disk
  • Next by thread: Re: problem writing out XML suite parsed file to disk
  • Index(es):
    • Date
    • Thread