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.
IndexSuggestions & BugsWebsite,  Documentation,  Book Bugs › exit() not behaving like reference says
Page Index Toggle Pages: 1
exit() not behaving like reference says (Read 769 times)
exit() not behaving like reference says
Nov 14th, 2007, 1:46am
 
I've got trouble understanding how exit() works. According to the reference,

Quote:
Rather than terminating immediately, exit() will cause the sketch to exit after draw() has completed.


But the output of the following sketch
Code:
void setup() {
size(100,100);
println("Before exit()");
exit();
println("After exit()");
}

void draw() {
println("draw()");
line(0,0,width,height);
}


is

Code:

Before exit()
After exit()


So draw() is not called at all, and still exit() does not terminate the program immediately. What am I missing?
Re: exit() not behaving like reference says
Reply #1 - Nov 14th, 2007, 2:23am
 
Hmmm you might not be able to call exit() during setup. I believe it's supposed to be explicitly used in draw() and may be victim to some documentation oversight.

From what I understand exit() signals an exit call WITHIN draw() so that once draw finishes the program will stop and draw will cease to become looped.
Re: exit() not behaving like reference says
Reply #2 - Nov 15th, 2007, 8:23pm
 
i'll change the reference to say "after draw() has completed (if called inside draw) or after setup() has completed (if called during setup)".
Re: exit() not behaving like reference says
Reply #3 - Nov 21st, 2007, 8:15pm
 
Okay, thanks for straightening this out.
Page Index Toggle Pages: 1