pjhayward's Pascal Tutorial


pjhayward.net Home

Got a question?

Tutorial Home
Preparation
Lesson One - Sample Program
Lesson Two - Program Structure
Lesson Three - Data Types
and Constants
Lesson Four - Variables
Lesson Five - Text I/O
Lesson Six - Subroutines
Lesson Seven - Conditional
Statements
Lesson Eight - Arrays
Lesson Nine - Loops
Lesson Ten - Units
How to make your program wait
Two examples: First, how to make your program wait a specific amount of time, then continue.

//You have a choice here.  You can either define your own delay function, like this:
//Procedure Delay(DTime: Word);
//{
//  Wait for DTime milliseconds.
//}
//Begin
//  Select(0,nil,nil,nil,DTime);
//End;

//or you can use the CRT unit, like this:
//uses crt;


const
  timeInMilliseconds=1000; //equals 1 second
begin
  ...
  delay(timeInMilliseconds);
  ...
end;

The second type of wait is to wait for user input. Assuming you've got a command line application, you can use this:

begin
  write("Waiting for user input: ");
  readln; //waits for user to press enter, without regard to anything actually typed.
end;

If you're using the CRT unit, the following should also work:

uses crt;

begin
  readkey; //reads a key - if no key is pressed, waits until one has been.
end;

Hope that helps!

Back to Question/Answer list