Hi All,
So I did build this nice script in AppleScript, but now I want to build an interface.
So I moved to XCode 3.2.6. I had to change some file handling using the ‘current application’ statement.
And it worked in most instances. But can’t get it to work here:
original Applescript code:
set theXmlFile to (choose file with prompt "Choose the XML file:" of type {"XML"}) as string
tell application "System Events"
set theXmlData to XML file theXmlFile
end tell
but after moving to XCode I tried hundred’s of versions of the ‘current application’ statement, but can’t get this thing to work in System Events.
I started with trying:
tell current application to set theXmlFile to (choose file with prompt "Choose the XML file:" of type {"XML"})
tell application "System Events"
set theXmlData to XML file theXmlFile
end tell
but got the error System Events got an error: Can’t make alias “(file path)” into type integer. (error -1700)
I tried :
tell current application to set theXmlFile to ((choose file with prompt "Choose the XML file:" of type {"XML"}))
set theXmlFileInt to (open for access current application's file theXmlFile)
tell application "System Events"
set my theXmlData to XML file (theXmlFile)
end tell
But get the error Can’t make file [alias [pathtofile]] into type «class fsrf». (error -1700)
And when I try:
tell current application to set theXmlFile to (choose file with prompt "Choose the XML file:" of type {"XML"})
tell application "System Events"
tell current application to set aFileRef to open for access theXmlFile
set theXmlData to contents of XML file aFileRef
tell current application to close access aFileRef
end tell
The error is a wrong index… (although it is an integer now… but apparently not the integer it was looking for?)
Tried several other options, to no avail.
Obviously the goal is to get XML data from the theXMLData variable. Something like this:
tell application "System Events"
tell theXmlData
tell XML element "name"
set thisList to the value of (every XML element)
end tell
end tell
end tell
As long as I stay in AppleScript Editor, this all works fine.
The problem came when I went over to Xcode.
Does anybody know how to solve this?
Of course I am aware that I have lots to learn about files, aliases, references, etc. I a, just confuesd. Maybe this example will help me understand better.
thanks a million.
rienq