We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I would like to perform some operations before quitting a sketch. I found on forums that method stop() is called before the application quits. I tried it, but it seems to me it is never called. Here follows a minimal (not working) example.
void setup()
{
size(100,100);
println("start");
}
void draw()
{
//nothing here
}
void stop()
{
println("called stop()");
}
Answers
I answered this question here.
Please link between crossposts, that way people don't waste their time answering questions that have already been answered.
http://forum.processing.org/two/discussion/9408/run-code-when-closing-without-interfering
mmm the function exit() -proposed in the link- works if you close the sketch through the X, not if you hit the stop button
To stop a sketch use
System.exit (0);
and place any closin actions in the
exit
method already mentioned.According to Processing's API reference, we should use exit():
http://processing.org/reference/exit_.html
System.exit(0);
is Java-ish style. Will it really invoke Processing's exit() as well? O_oGoToLoop I should have taken more time over answering this question. Your points are vaild.
valerio_sperati please ignore my previous comment.