FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Website, Reference, Example Bugs
(Moderator: REAS)
   delay()
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: delay()  (Read 748 times)
kevinP

Email
delay()
« on: Feb 16th, 2004, 7:01pm »

Hi,
 
It's not really an error, perhaps, but I see that it tripped somebody else up as it did me. The reference page says:
 
" Forces the program to stop running for a specified time. Delay time are specified in thousandths of a second. The function call delay(3000) will stop the program for three seconds."
 
But what it doesn't make clear is that delay() really only stops the loop(). Toxi's explanation helps: "delay() will not actually pause the sketch immediately, only specifies the time between loops."
« Last Edit: Feb 16th, 2004, 7:03pm by kevinP »  

Kevin Pfeiffer
toxi_
Guest
Email
Re: delay()
« Reply #1 on: Feb 16th, 2004, 7:28pm »

actually, i was wrong! delay() stops the thread immediately, only not in the first iteration of the loop() method.
 
Code:
void loop() {
  println("x");
  delay(1000);
  println("y");
  delay(1000);
}

 
sorry about the confusion!
 
kevinP

Email
Re: delay() (but...)
« Reply #2 on: Feb 18th, 2004, 9:05am »

Hmmm... then try this:
 
[oops, deleted]
 
(Forgot to read the second half of your answer.)
 
"only not in the first iteration of the loop..." then is the part we should add to the docs.
 
-K
« Last Edit: Feb 18th, 2004, 9:08am by kevinP »  

Kevin Pfeiffer
REAS


WWW
Re: delay()
« Reply #3 on: Jul 8th, 2004, 3:26am »

I've modified the text for delay() to:
Quote:
Forces the program to stop running for a specified time. Delay times are specified in thousandths of a second. The function call <b>delay(3000)</b> will stop the program for three seconds. This function causes the program to stop as soon as it is called, except if the program is running the loop() for the first time it will complete the loop before stopping.

 
I haven't tested Toxi's statement, but I'll assume it works as he says.
 
Pages: 1 

« Previous topic | Next topic »