We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Export values to a .txt file
Page Index Toggle Pages: 1
Export values to a .txt file (Read 557 times)
Export values to a .txt file
Apr 3rd, 2009, 5:20am
 
Hey Processing-community,

short question: I am using createWriter() to export some values of my application into a text file. Though how can i use specific tabs in this file. So instead of "\t" can I use a specific value?
And how could I determine the amount of tabs/spacebars according to a value i?
(to for instance show a matrix: the first value has to be with 0 tabs, the second has to be after 1 tab, etc etc)

Thanks in advance!
Re: Export values to a .txt file
Reply #1 - Apr 3rd, 2009, 7:29am
 
I don't understand what you mean by "specific tabs".
Anyway, I think that you write what you put in: so just replace TAB or "\t" with whatever you need.

I fear I don't understand either the second question. Just put the tab or separator at the wanted places, no?
Re: Export values to a .txt file
Reply #2 - Apr 3rd, 2009, 7:59am
 
note sure, but did you mean something like that ?

PrintWriter output;

void setup() {
 // Create a new file in the sketch directory
 output = createWriter("positions.txt");
}

void draw() {

for(int i = 0; i<20; i++){
 for(int j = 0; j<i; j++)output.print("\t"); // adds Tabs
 output.println(i); // Writes i
}

 output.flush(); // Writes the remaining data to the file
 output.close(); // Finishes the file
}
Re: Export values to a .txt file
Reply #3 - Apr 4th, 2009, 4:47am
 
exactly what I meant, thanks!

(in exact form:
Code:

for(int i=0; i<20; i++){
for(int j=0; j<i; j++) {
if (j == (i-1)) { output.println("Here is: "+i); break;} // Writes i
else { output.print("\t"); } // adds Tabs
}
}
Page Index Toggle Pages: 1