FAQ

How do I... ?

When I run my program the console window appears only fleetingly. How can I make it remain?
Insert a readln; statement immediately before the final end. If that does not work, check for run-time errors. See common run-time errors in our checklist of common programming errors.
How can I stop my programs crashing when I enter the wrong data type by mistake?
You should include validation code so that the program will not accept data of the wrong type. See our tutorial on validation.
I have an output of 1.25663706143591E+0001 for my real variable Circumference. How do I make it display 12.57?
Include the field width and number of decimal places e.g. writeln(Circumference:6:2);
How do I output the £ sign using a writeln statement?
Use its ASCII code e.g. writeln(chr(156),Cost);
How do I display an apostrophe using a writeln statement?
Type two consecutive apostrophes. (Can you think why using only one apostrophe causes problems?)
How do I indent a block of text in the editor?
Type Ctrl+I in Lazarus or Ctrl+K+I in Delphi.
How do I unindent a block of text in the editor?
Type Ctrl+U in Lazarus or Ctrl+K+U in Delphi.
How do I create a delay?
Use the inbuilt procedure sleep(Duration), where Duration is in milliseconds.
How do I make the computer output music?
For each note, use the inbuilt procedure windows.beep(Frequency, Duration), where Duration is in milliseconds.
How do I input a hexadecimal number?
The statement is, for example, readln(Num), where Num is an integer variable. For the data entry, precede the hexadecimal representation with the $ symbol e.g. $8F.
How do I compute an exponential?
Add Math to the uses section then use the power function with real variables
y := power(x, z);

Errors

I am working in the Delphi IDE and I see the error message, “Could not create output file”.  What is the likely cause?
Make sure that you have saved the program file.
I am working in the Lazarus IDE and I see the error message, “Error while linking”.  What is the likely cause?
Make sure that you have saved the program file.

Why... ?

Why do you not use validation in most of the programs in your tutorials?
The programs are intended to be as simple as possible to illustrate key points clearly.
Why do you put a semicolon after the last statement in a block when there is no following statement from which to separate it?
It does no harm and the semicolon is already in place if code is appended later.
Programming - a skill for life!

Getting Started, Links and other resources