comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey D. Cherry" <yrrehcdj@hcetu.ten>
Subject: Re: Delay
Date: Wed, 10 Jul 2002 16:01:20 -0000
Date: 2002-07-10T16:01:20+00:00	[thread overview]
Message-ID: <Xns92475BF0AC1CAjdcherryutechnet@216.168.3.40> (raw)
In-Reply-To: 3D2C3CE1.1080501@yahoo.com

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




      parent reply	other threads:[~2002-07-10 16:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
replies disabled

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