Page 1 of 1

Creating a text file from a standalone

Posted: Thu Aug 27, 2009 8:52 am
by sketchpad92
I'm creating an experiment where once the data is collected, it needs to be put into a text file and stored in a data directory. I used a url to create the text file in the code originally before I made the standalone and the program created its own text file just fine. But a text file isn't created when I run the standalone. I'm very new to standalones, and don't really know how they operate. I do know that standalones in other programs are perfectly capable of creating a text file. Can anyone give me some direction about how I might accomplish this? Thanks.

Posted: Thu Aug 27, 2009 8:58 am
by Klaus
Hi sketchpad92,

that's pretty simple, just put the variable or field with the text into an "url" like this:
...
put Variable_with_the_generated_text into url("file:" tTargetfolder & "the_text_file.txt")
## Of course you have to fill the variable "tTargetFolder" with a valid folder path first! ;-)
...

This will work in the IDE and standalone.

Check "url" and "put" in the docs (Revolution Dictionary)!


Best

Klaus

Posted: Thu Aug 27, 2009 9:16 am
by sketchpad92
Thanks Klaus!

Weird though, doesn't work. I tried your version, and mine...

--put "file:"&dataPath&"M"&the ticks into fName
--put x & return&photolist into URL fName
put x&return&photolist into url("file:"&dataPath&"M"&the ticks&".txt")

The text file outputs if I just run the regular program, but does not when I create the standalone. I tried moving the standalone into the same directory as the data folder (contained in dataPath) and the stimuli, doesn't matter. I'm wondering if there's something I'm missing about these standalones. Is there something in the settings perhaps that I am not doing?

Posted: Thu Aug 27, 2009 10:16 am
by Klaus
Hi sketchpad92,

hmm, you could add this line:
...
put x&return&photolist into url("file:"&dataPath&"M"&the ticks&".txt")
ANSWER THE RESULT
...

"the result" is EMPTY if the file was written succesfully, but will contain an hint on what might have gone wrong if not.


Best

Klaus

Posted: Thu Aug 27, 2009 10:32 am
by SparkOut
What operating system are you trying this on? You might be running into permissions problems in the location you're trying to save the file to for instance. Say on Windows (in particular in Vista with virtualisation switched on) you might not be able to right the file alongside the executable in the Program Files folder.
If windows, you could use the application data folder for the purpose of storing the text file, using the specialFolderPath(28) (for individual user) or maybe specialFolderPath("preferences") for Mac, etc.
http://www.sonsothunder.com/devres/revo ... ile010.htm is a great source of info about what folder path codes are available.

The other thing to check is that the right file path separators are being used for the operating system. In theory natively inside Rev it shouldn't matter and a forward slash is used, but if on Windows you might try replacing with a backslash. For that matter, I don't see a slash char in your script sample, have you included that at the end of the dataPath variable? I'm assuming that the "M" is a filename prefix you want, and not a separator substitute?

Problem Solved!

Posted: Thu Aug 27, 2009 1:17 pm
by sketchpad92
Hi guys,

I want to thank you both for your help on this. It's nice to know that there is somewhere to turn when these issues arise. I figured out the problem. In my code, I used a general way to store the path of the two folders (image and data) by putting the filename of the stack into the variable. I guess that messes with the program, because once I directly pasted the exact path of the stack into the variable, everything worked just fine.

Thanks so much!!

Posted: Thu Aug 27, 2009 1:27 pm
by Klaus
Okie Dokie!
We'll send you the invoice at the end of the month! :lol: :lol: :lol:

Posted: Thu Aug 27, 2009 1:42 pm
by sketchpad92
Haha!! I'll gladly pay it!!!

Thanks again!