Pascal - Environment Set Up


Try it Option Online

We have set up the Pascal Programming environment online, so that you can compile and execute all the available examples online. It gives you confidence in what you are reading and enables you to verify the programs with different options. Feel free to modify any example and execute it online.

Try the following example using our online compiler available at CodingGround

program HelloWorld;
uses crt;

(* Here the main program block starts *)
   writeln('Hello, World!');

For most of the examples given in this tutorial, you will find a Try it option in our website code sections at the top right corner that will take you to the online compiler. So just make use of it and enjoy your learning.

There are several Pascal compilers and interpreters available for general use. Among these are −

  • Turbo Pascal − provides an IDE and compiler for running Pascal programs on CP/M, CP/M-86, DOS, Windows and Macintosh.

  • Delphi − provides compilers for running Object Pascal and generates native code for 32- and 64-bit Windows operating systems, as well as 32-bit Mac OS X and iOS. Embarcadero is planning to build support for the Linux and Android operating system.

  • Free Pascal − it is a free compiler for running Pascal and Object Pascal programs. Free Pascal compiler is a 32- and 64-bit Turbo Pascal and Delphi compatible Pascal compiler for Linux, Windows, OS/2, FreeBSD, Mac OS X, DOS and several other platforms.

  • Turbo51 − It is a free Pascal compiler for the 8051 family of microcontrollers, with Turbo Pascal 7 syntax.

  • Oxygene − It is an Object Pascal compiler for the .NET and Mono platforms.

  • GNU Pascal (GPC) − It is a Pascal compiler composed of a front end to GNU Compiler Collection.

We will be using Free Pascal in these tutorials. You can download Free Pascal for your operating system from the link: Download Free Pascal

Installing Free Pascal on Linux

The Linux distribution of Free Pascal comes in three forms −

  • a tar.gz version, also available as separate files.

  • a .rpm (Red Hat Package Manager) version.

  • a .deb (Debian) version.

Installation code for the .rpm version::

rpm -i fpc-X.Y.Z-N.ARCH.rpm

Where X.Y.Z is the version number of the .rpm file, and ARCH is one of the supported architectures (i386, x86_64, etc.).

Installation code for the Debian version (like Ubuntu):

dpkg -i fpc-XXX.deb

Where XXX is the version number of the .deb file.

For details read: Free Pascal Installation Guide

Installing Free Pascal on Mac

If you use Mac OS X, the easiest way to use Free Pascal is to download the Xcode development environment from Apple's web site and follow the simple installation instructions. Once you have Xcode setup, you will be able to use the Free Pascal compiler.

Installing Free Pascal on Windows

For Windows, you will download the Windows installer, setup.exe. This is a usual installation program. You need to take the following steps for installation −

  • Select a directory.

  • Select parts of the package you want to install.

  • Optionally choose to associate the .pp or .pas extensions with the Free Pascal IDE.

For details read: Free Pascal Installation Guide

Text Editor

This will be used to type your program. Examples of few editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi.

Name and version of text editor can vary on different operating systems. For example, Notepad will be used on Windows and vim or vi can be used on windows as well as Linux or UNIX.

The files you create with your editor are called source files and contain program source code. The source files for Pascal programs are typically named with the extension .pas.

Before starting your programming, make sure you have one text editor in place and you have enough experience to write a computer program, save it in a file, compile it and finally execute it.