Creating a text file from a standalone
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 7
- Joined: Tue Apr 28, 2009 6:33 pm
Creating a text file from a standalone
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.
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
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
-
- Posts: 7
- Joined: Tue Apr 28, 2009 6:33 pm
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?
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?
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?
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?
-
- Posts: 7
- Joined: Tue Apr 28, 2009 6:33 pm
Problem Solved!
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!!
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!!
-
- Posts: 7
- Joined: Tue Apr 28, 2009 6:33 pm