Problem from a beginner with the file text save and String []
Hi everybody,
I'm a french beginner on processing.
I want to realize a mouse click counter who to record my counter in the file text and when I restart the program, I want to restart to count directly on my last value from my file text.
Actualy, I've got the first part, my sketch count and save my mouse click in the file text.
But I can't restart to count with my last file text value in the draw()…
Please, if anybody have a solution form me ?
This is my sketch:
int compteur = 0; // my counter
String [] newcompteur;
void setup() {
size(500, 500);
background (0);
String[] newcompteur = loadStrings ("compteur.txt"); // read my save file
println(newcompteur);
text (newcompteur[compteur],250, 250);
}
void draw() {
// When I click with my mouse
if (mousePressed == true) {
delay(100); // delay for the mouse click
background (0);
compteur += 1; // my counter
String[] newcompteur = new String[1];
newcompteur[0] = compteur+"";
saveStrings("compteur.txt", newcompteur);
text (newcompteur[0],250, 250);
println (newcompteur);
}
}
Thank you for yours solutions and forgive my english : )
Olivier