i was wondering if it would be possible to use a timer in pascal. like for instance you have 10 seconds to answer a question. iv been thinking and i cant figure out how to do it. does anyone know how?

Hi all
I have an idea for this question :)

Program Solution01;
Uses Crt;
Label start,good,finish,timeout;
Var i:Byte;  {0..255}
    U,P:String;
Begin {main}
   P:='apple';
   start:
      i:=10;
      Repeat
         WriteLn('REMAINING TIME: ',i);
         Write('GIVE ME THE PASSWORD: ');
         Dec(i);{decrease value of 'i' by 1}
         Delay(1000); {waiting 1000 millisec}
         ClrScr;
         If (i=0) Then Begin
            GoTo timeout; {if the time's up}
         End;
      Until KeyPressed;
      Write('GIVE ME THE PASSWORD: ');
      ReadLn(U);
      If (U<>P) Then Begin
         ClrScr;
         Write('WRONG ANSWER ENTERED.');
         Delay(1000);
         GoTo finish; {this jumps to the finish label}
      End
      Else GoTo good;
   timeout:
      Begin
         Write('TIME''S UP....');
         GoTo finish;
      end;
   good:
      Write('GOOD ANSWER!');
   finish:
      ReadLn;
End.
{

-=Note By FlamingClaw=-
In pascal, the instructions followes each other line by line,but the
'GoTo' command can jump over the other commands.
Sometimes we have to use the 'GoTo' command.In generally not recommended.
Of course tesed,and working in Dev Pascal 1.9.2
-=Created By FlamingClaw=-
-=2009.04.11=-

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.