Hello, guys, and thank you in advance!
I am trying to make the program stop running for six seconds. I don't know, however, how to use the system clock. The code I came up with is something like this:

PROGRAM TIMER;

VAR
LINE:STRING;
X, S:INTEGER;

BEGIN

REPEAT
WRITE ('TYPE ANYTHING TO BEGIN: ');
READLN (LINE);
IF LINE<>'0' THEN
BEGIN
RANDOMIZE;
X := RandSeed
S := X + 6000;
REPEAT
RANDOMIZE;
UNTIL RandSeed >= S
WRITELN ('END OF TIME!');
END;
UNTIL LINE='0';

END.


It works, somehow, but it's not accurate, atleast not as acurate as a real timer. If somebody can help me, please, do so. Thank you, once more!

program Timer;

{$mode objfpc}{$H+}

uses
  Classes, DateUtils, SysUtils
  { add your units here };
var
   TargetTime: TDateTime;
begin;
    TargetTime := IncSecond(Now, 6);
    repeat
    until CompareTime(Now, TargetTime) >= 0;
    WriteLn('Six seconds have elapsed!');
end.

The last time when I used Pascal was ages ago, but I do remember a function delay(), i.e. delay(6); gives u a delay from 6 seconds. Maybe you need to use Crt (or if there is a new name for it) to get it - this you have to check.

I have heard of that command before, but, unfortunately, it doesn't seem to be supported by the edition of Pascal I use (that would be DevPascal). thanks for the tip, anyway!

As for the source code sant by Jackrabbit, I have no clue as to how to use units. You see, I learnt Pascal on my own, using a book written in 1990... You understand that my knowledge is not sufficient to develop something REALLY good. I appreciate your help, though! I really do!

This article has been dead for over six months. Start a new discussion instead.