[fpc-devel] Coding Questions

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Sat Dec 3 12:26:53 CET 2005


On 12/2/05, VisionForce <webmaster at visionforceweb.com> wrote:
> Dim DelayAmount, DelayCount As Integer
> DelayCount = 250
>
> If (Environment.TickCount - DelayAmount) >= DelayCount Then
>    ' run code here
>    DelayAmount = Environment.Tick
> End If

Maybe you can check TEpikTimer. I used it to get nanosecond resolution
for a Digital Osciloscope project witch needed precise timing between
the voltage measures.

Works great on both Linux and Windows, but requires Lazarus LCL.

To wait some time before continuing I write code using it like this:

 DelayInSeconds := 8; // or any value
 OldTime := ET.Elapse;

 while ((1000000.0 * (ET.Elapsed - OldTime)
  < DelayInSeconds)) do
 begin
   ET.SystemSleep(0);
 end;

  // DelayInSeconds has elapsed and now you can continue executing the code


You can find more information (including download) here:
http://wiki.lazarus.freepascal.org/index.php/EpikTimer#Usage

I recently improved the component, and the updated version is
available for download.

One particular issue with it is that the component is in the standard
LGPL, witch prohibits static linking between proprietary and the
component, but you can contact the author if this is a problem for
you.

--
Felipe Monteiro de Carvalho



More information about the fpc-devel mailing list