Forum > General
Delay
(1/1)
michoux:
Hello,
I am using follwoing code to make a delay of a seconds ...
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- procedure Delay1(TickTime : Integer); var Past: longint; begin Past := GetTickCount; repeat application.ProcessMessages; Until (GetTickCount - Past) >= longint(TickTime);end;
It works om my laptop win10 but not on second laptop also win10, delay is simply not followed ...
winni:
Hi!
For test reasons add a Label and an Integer i.
This code will schow you every second the progress
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Delay1(TickTime : Integer); var Past: longint; i : Integer =0; begin Past := GetTickCount; repeat inc(i); if i mod 1000 = 0 then Label1.Caption := IntToStr(i); application.ProcessMessages; Until (GetTickCount - Past) >= longint(TickTime);end;
Winni
Jurassic Pork:
Hello,
--- Quote from: michoux on June 18, 2021, 05:06:56 pm ---It works om my laptop win10 but not on second laptop also win10, delay is simply not followed ...
--- End quote ---
have you the same version of lazarus and fpc on the two laptops? 32 bits ? 64 bits ?
--- Quote ---GetTickCount (deprecated)
Get tick count (32-bit, deprecated)
Declaration
Source position: sysutilh.inc line 28
function GetTickCount: LongWord;
Description
GetTickCount returns an increasing clock tick count in milliseconds. It is useful for time measurements, but no assumptions should be made as to the interval between the ticks. This function is provided for Delphi compatibility, use GetTickCount64 instead.
--- End quote ---
--- Quote ---GetTickCount64
Get tick count (64-bit)
Declaration
Source position: sysutilh.inc line 29
function GetTickCount64: QWord;
Description
GetTickCount64 returns an increasing clock tick count in milliseconds. It is useful for time measurements, but no assumptions should be made as to the interval between the ticks.
--- End quote ---
Friendly, J.P
BobDog:
Call it sleep.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- program sleep; usesSysUtils,DateUtils; procedure sleep(t:integer);varD1: TDateTime;begin D1:=now; repeat until MilliSecondsBetween(now,D1) >= tend; var i:integer;beginfor i:=1 to 10 dobeginwriteln(TimeToStr(Time)) ;sleep(1000) ;end;writeln('Press enter to end . . .');readln;end.
Navigation
[0] Message Index