How to schedule the execution of a function in 5 seconds with Pascal

1 Answer

0 votes
program ScheduleFunction;

uses
  SysUtils;

procedure MyFunction;
begin
  WriteLn('Function executed after 5 seconds!');
end;

begin
  WriteLn('Waiting for 5 seconds...');
  Sleep(5000); // Pause for 5000 milliseconds (5 seconds)
  
  MyFunction;  // Call the function
end.

 
 
 
(*
run:
 
Waiting for 5 seconds...
Function executed after 5 seconds!
 
*)

 



answered Jun 23, 2025 by avibootz
...