Saving results w/o dialog box

I want to administer a simple experimental test to subjects and automatically save the results to a file named “TestResults” on the computer’s desktop after the user clicks the last button, without the user having to deal with a dialogBox.

I tried the code below with two alternative version of the “fileStream = “ command and neither worked.

dim gOpenFile as FolderItem
dim fileStream as TextOutputStream
dim limit as string
dim msg as string

limit = CHR(9) // tab-delimited

gOpenFile = New folderitem
gOpenFile.name = “TestResults”
//fileStream = gOpenFile.CreateTextFile
fileStream = TextOutputStream.Create(gOpenFile)
msg = “total number of unique tickers” + limit + str(1)
fileStream.WriteLine msg

fileStream.close

Try changing the lines

gOpenFile = New folderitem gOpenFile.name = "TestResults"

to

gOpenFile = SpecialFolder.Desktop.Child("TestResults")

Which will create a folder item that refers to “TestResults” on the current users desktop.

That worked!

Thanks Wayne, I really appreciate it.