Create text file from AppleScript Results

Posted on 2010-01-05
Last Modified: 2012-06-27
I am having a horrible time getting the results of an AppleScript to go anywhere with exception to the Results pane below in AppleScript Editor.  See the code below.  This will call the appropriate data from an application and dump a bunch of text in the Results area below...however, I actually want the results to either feed into MySQL database, Filemaker database or EVEN JUST A SIMPLE TEXT FILE ON THE DESKTOP.  It just won't do it.
set nametosearch to "(patientID LIKE '*')"

tell application "http://localhost:8100"


		set returndata to call xmlrpc {method name:"DBWindowFind", parameters:{request:nametosearch, table:"Study", execute:"Nothing"}}

		return returndata

	on error (errorname)

		return errorname

		tell application "TextEdit"



				make new document

				set text of document 1 to returndata as text

				save document 1 in "/Users/weklica/Desktop/LastUpdater.txt"

			end try

		end tell

	end try

end tell

Open in new window

Question by:weklica

    Author Comment

    It basically runs the same with or wtihout the 'tell application 'TextEdit" .... material.  As if it isn't even in there after 'return errorname'..... No errors.  It runs all the same?!?!

    Accepted Solution

    Nevermind.  Got it.

    set nametosearch to "(patientID LIKE '*')"

    tell application "http://localhost:8100"
          set returndata to call xmlrpc {method name:"DBWindowFind", parameters:{request:nametosearch, table:"Study", execute:"Nothing"}}
          set newFile to "/Users/weklica/desktop/testering.txt"
    end tell
    open for access newFile with write permission
    set eof of newFile to 0
    write returndata to newFile
    close access newFile


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    CocoaPods is the best way to manage library dependencies in iOS and OS X projects. By using cocoa pods there is no need of downloading the code from github and copying to your project. There are plenty of open source libraries now available with C…
    Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now