comp.lang.ada
 help / color / mirror / Atom feed
* Delay
@ 2002-07-10 13:55 David Rasmussen
  2002-07-10 14:17 ` Delay David C. Hoos
  2002-07-10 16:01 ` Delay Jeffrey D. Cherry
  0 siblings, 2 replies; 3+ messages in thread
From: David Rasmussen @ 2002-07-10 13:55 UTC (permalink / raw)


How do I make a delay in an Ada program?

/David




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Delay
  2002-07-10 13:55 Delay David Rasmussen
@ 2002-07-10 14:17 ` David C. Hoos
  2002-07-10 16:01 ` Delay Jeffrey D. Cherry
  1 sibling, 0 replies; 3+ messages in thread
From: David C. Hoos @ 2002-07-10 14:17 UTC (permalink / raw)


To delay a minimum of a fixed amount of time

delay <Duration-expression>;

e.g. delay 0.5; -- delay half a second

To delay at least until some appointed time

delay until <Ada.Calendar.Time-expression>

e.g.:

Next_Time : Ada.Calendar.Time;
use type Ada.Calendar.Time;
.
.
.
-- Make sure the following loop executes once per second
Next_Time := Ada.Calendar.Clock;
loop
    .
    .
   Next_Time := Next_Time + 1.0;
   delay until  Next_Time;
end loop;
 
----- Original Message ----- 
From: "David Rasmussen" <pinkfloydhomer@yahoo.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Wednesday, July 10, 2002 8:55 AM
Subject: Delay


> How do I make a delay in an Ada program?
> 
> /David
> 
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
> 




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Delay
  2002-07-10 13:55 Delay David Rasmussen
  2002-07-10 14:17 ` Delay David C. Hoos
@ 2002-07-10 16:01 ` Jeffrey D. Cherry
  1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey D. Cherry @ 2002-07-10 16:01 UTC (permalink / raw)


David Rasmussen <pinkfloydhomer@yahoo.com> wrote in news:3D2C3CE1.1080501
@yahoo.com:

> How do I make a delay in an Ada program?
> 
> /David
> 

Use the 'delay' statement.  Refer to section 9.6 of the Ada Reference 
Manual.

From section 9.6 of the Ada RM:

"A delay_statement is used to block further execution until a specified 
expiration time is reached. The expiration time can be specified either as a 
particular point in time (in a delay_until_statement), or in seconds from 
the current time (in a delay_relative_statement)."

Examples from that same section:

"Example of a relative delay statement:

   delay 3.0;  -- delay 3.0 seconds

Example of a periodic task:

   declare
      use Ada.Calendar;
      Next_Time : Time := Clock + Period;
                         -- Period is a global constant of type Duration
   begin
      loop               -- repeated every Period seconds
         delay until Next_Time;
         ... -- perform some actions
         Next_Time := Next_Time + Period;
      end loop;
   end;"

Note that the data type of the delay expression (the value appearing after 
the reserved word 'delay') differs in the two forms of the delay statement.  
The relative delay accepts a delay expression of type duration (a standard 
data type) while the delay until accepts a value of some "time" type.  The 
example above shows that the delay until uses the data type "Time" defined 
in the standard package Ada.Calendar.

Hope that helps!


-- 
Regards,
Jeffrey D. Cherry
Senior IV&V Analyst
Northrop Grumman Information Technology




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-07-10 16:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-10 13:55 Delay David Rasmussen
2002-07-10 14:17 ` Delay David C. Hoos
2002-07-10 16:01 ` Delay Jeffrey D. Cherry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox