I've been having trouble saving the printed data (co-ordinates and seconds) more than once when a key is pressed.
The aim is to try and save 'println' data to a file live and continuously while the programme is running.
At the moment, all I can seem to do is save data to a file until i press a key for the first time - then it stops recording,
Please help!
Richard
PrintWriter output;
void setup() {
// Create a new file in the sketch directory
output = createWriter("data_stream_time.txt");
}
void draw() {
point(mouseX, mouseY);
println (millis() / 1000);
println(mouseX + "t" + mouseY); // Write the coordinate to the file
output.println(mouseX + "t" + mouseY); // Write the coordinate to the file
output.println (millis() / 1000);
}
void keyPressed() {
output.flush(); // Writes the remaining data to the file
output.close(); // Finishes the file
redraw(); //redraws the programme when a letter is typed, flushes the data to the file
}
//only saves the first instance before you press a key. Afterwards it doesn't save!
The aim is to try and save 'println' data to a file live and continuously while the programme is running.
At the moment, all I can seem to do is save data to a file until i press a key for the first time - then it stops recording,
Please help!
Richard
PrintWriter output;
void setup() {
// Create a new file in the sketch directory
output = createWriter("data_stream_time.txt");
}
void draw() {
point(mouseX, mouseY);
println (millis() / 1000);
println(mouseX + "t" + mouseY); // Write the coordinate to the file
output.println(mouseX + "t" + mouseY); // Write the coordinate to the file
output.println (millis() / 1000);
}
void keyPressed() {
output.flush(); // Writes the remaining data to the file
output.close(); // Finishes the file
redraw(); //redraws the programme when a letter is typed, flushes the data to the file
}
//only saves the first instance before you press a key. Afterwards it doesn't save!
1