6.1.5 Compiling your first program

To ensure that IDE is working and is setup properly, it is recommended that your first program is as simple as possible, but with useful feedback. A simple ”Hello world!” program is a great choice. Open ”File—New” and enter the following program:

begin
  writeln('Hello world!');
end.

Save the program with ”File—Save as”. The program has to be saved before it can be compiled.

The next step is to test your program. Select the menu item ”Run—Run” or press Ctrl-F9 (section 6.8, page 248). This command compiles your program if it was not already compiled or if it was modified since the last compile, and runs it. In case of success you will see a ”Hello world!” message printed on the screen. Press Alt-F5 to see the User screen when the program has returned to the IDE.

Compilation can fail. Failing is a normal part of development. In such a case, address the issue identified by the error message. Keep compiling until the program compiles successfully and the program can be run.

Here is how to resolve error: Fatal: Can’t find unit system used by Program.

Open ”Options—Directories…” and in tab Units enter valid path to location of system.ppu (section 6.11.2, page 320). If you have entered path, but error persists then open ”Options—Compiler…” in tab Verbose check Used, tried info to get more information during compilation for further troubleshooting.

Remark
The IDE encorporates the compiler and it does not need to locate the command line compiler. The location of used units has to be supplied. The system unit is used implicitly by every program and unit. The IDE does make an educated guess and tries to preconfigure the location of units shipped with Free Pascal.