How to Learn PASCAL

Pascal is a purely procedural programming language that was developed in 1971 to teach students the basic ideas of programming. Named after Blaise Pascal, the philosopher mathematician, it belongs to the ALGOL family of programming languages. In 1993, Borland Software Corporation added object-oriented extensions to standard Pascal to create Delphi Pascal, much like Basic became Visual Basic.

Instructions

    1

    Obtain a free Pascal compiler. These are available from sites such as Freepascal.org and Thefreecountry.com (under "Free Compilers/Interpreters"). Download the compiler of your choice and install it on your system.

    2

    Open the text editor or IDE that comes with the compiler and copy and paste the language sample below. Then save it as "first.pas." The simplest form of Pascal program has a name (after the "program" keyword) and a main body with commands (defined by the begin/end keywords). This program displays "Hello Pascal!" to the screen until the user presses Enter.




    program First;

    begin

    Write('Hello Pascal!');

    Readln;

    end.

    3

    Compile and run the program. To compile through the IDE, pressing Ctrl+F9 usually works. To compile from the command line, type "fpc first.pas."

    4

    Add units into the program to give access to built-in commands. You add units after the "uses" keyword. Here, "crt" gives rise to the "ClrScn" command which clears the screen. Modify the code to look like the language sample below. Then compile and run it to see the change.



    program First;

    uses

    crt;

    begin

    ClrScr;

    Write('Hello Pascal!');

    Readln;

    end.

    5

    Insert comments into your code. These comments explain to other programmers what the program does. In Pascal, comments are encased in braces "". The code in Step 4 appears below with comments inserted.



    This program clears the screen, prints "Hello Pascal" and continues doing so until the user presses Enter.

    program First;

    uses

    crt;

    begin

    ClrScr;clears the screen

    Write('Hello Pascal!');Prints "Hello Pascal!"

    Readln;waits for Enter

    end.

Blog Archive