Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- do shell script "/Users/Nick/Dropbox/Untitled.command"
- set theFile to "/Users/Nick/Documents/values.txt"
- open for access theFile
- set fileContents to (read theFile)
- close access theFile
- set costItems to {}
- set x to 1
- tell application "System Events"
- set XMLRoot to make new XML data with data fileContents
- repeat with searchItems in (XML elements of XML element "searchResult" of XML element "findItemsAdvancedResponse" of XMLRoot)
- set end of costItems to value of XML element "convertedCurrentPrice" of XML element "sellingStatus" of searchItems
- if x is not 5 then
- set x to x + 1
- else
- exit repeat
- end if
- end repeat
- end tell
- return costItems
- tell application "Finder"
- try
- set the_file to "/Users/Nick/Documents/outputvals.txt" as POSIX file as alias
- on error --file doesn't exist yet, so create it
- set the_file to (make new document file at ("/Users/Nick/Documents/" as POSIX file as alias) with properties {name:"outputvals", text:""})
- --Normally, when you're creating documents in this fashion, you would put the text you want in the document after the 'text' property, but for your sake I will use the alternative :)
- end try
- end tell
- set the_data to costItems
- try
- open for access the_file with write permission
- write the_data to file the_file starting at eof
- close access the_file
- on error --you never know when errors will crop up (when it comes to reading and writing files); better to be safe than sorry
- try
- close access the_file
- end try
- end try
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement