Recent

Author Topic: Freeze the code temporarily with Timer  (Read 2578 times)

sebaaller

  • Newbie
  • Posts: 1
Freeze the code temporarily with Timer
« on: March 05, 2013, 04:11:19 am »
Hi! I'd want to can freeze the code by some limited time. The idea is to stop running (for example) an procedure between two lines writing in the middle some code. My idea is that visualy have some changes in the screen but no instantly but with some time in the middle.
Does it have some way to obtain it? Thanks!

PD: Excuse me for my English... i wrote it with some help of google translate.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Freeze the code temporarily with Timer
« Reply #1 on: March 05, 2013, 06:06:46 am »
sleep(100); number is in miliseconds
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

laggyluk

  • Jr. Member
  • **
  • Posts: 69
Re: Freeze the code temporarily with Timer
« Reply #2 on: March 05, 2013, 08:27:35 am »
and to avoid interface freeze you can use something like that

Code: [Select]
procedure wait(n:integer);
begin
  while n>0 do begin
    dec(n);
    sleep(10);
    application.processmessages;
  end;
end;

tr_escape

  • Sr. Member
  • ****
  • Posts: 437
  • sector name toys | respect to spectre
    • Github:
Re: Freeze the code temporarily with Timer
« Reply #3 on: March 05, 2013, 12:40:50 pm »
Another code:

Code: [Select]
procedure delay(sn : double);
var
  t:double;  // also tdatetime
begin
  t := now + (((1.0/24.0)/60.0)/60.0)*sn;
  repeat
    application.ProcessMessages;
  until now>t;
end;

 

TinyPortal © 2005-2018