12

6 Easy Steps to Compile and Run a Pascal Program in Ubuntu

Michelle Rogers
This tutorial will teach you how to use FreePascal IDE to create, edit, and compile Pascal programs. The FreePascal IDE is a fast and convenient way to create and run your programs. While the GUI is very simplistic and plain, but it's very fast, easy, and intuitive.

To use this tutorial, you need to be running a version of Ubuntu and have FreePascal IDE for Linux i386, with compiler version 2.4.0-2 installed. The latest version of FreePascal IDE and the compiler can be found in the Ubuntu Software Center. This should work with any of the later versions of Ubuntu, though I have only tested this with version 10.04 Lucid Lynx.

1. Click on Applications to open the main menu. Highlight Accessories to open an adjacent menu and click on Terminal. When the Terminal opens type 'fp' then press enter. The FreePascal IDE should display in the Terminal (see picture).

2. Click "File" on the FreePascal IDE's menu bar and click "New" from the drop down menu. If you can't click on the menu, you can activate the menu by pressing Alt + the first letter of the menu item you want to access, then use the arrow keys to navigate the drop down menus. (If you already have a program written, you can open the file instead.)

3. You should now see the text editor inside the Terminal. Type your Pascal program, in the editor. Below is a simple program that outputs "Greetings! This is a sentence!" in the Terminal.

program howdy;

begin

writeln('Greetings! This is a sentence!');

readln;

end.

If your program has any errors, the debugger will most likely be able to identify them for you.

4. Now save the file by clicking on "File" from the menu again and click on "Save as..." or just press F2. A window will pop up inside the Terminal giving you the option to specify a name and location for the file. In this tutorial I chose to name the file "test.pas" and saved it in my Documents folder. Name the file and save it wherever you like.

5. Click on "Run" on the menu and click "Run" from the drop down that appears, or press Ctrl + F9. FreePascal IDE will automatically compile the program for you within seconds and begin executing it.

6. Your program should have been compiled and should be running in the Terminal window.

Your program will run and when the program stops, the Terminal will return you to the FreePascal IDE. You can exit the FreePascal IDE by simply clicking on "File" and "Exit", or by pressing Alt + x. When you exit, you will be returned to the Terminal.

To learn how to program in Pascal, I recommend the following website: http://www.learn-programming.za.net/programming_pascal_learn01.html. The tutorial is very easy to follow as the author explains the basics.

If you would like to learn more about the free Pascal compiler and IDE, please visit http://www.freepascal.org/.

1 Comments

Post a Comment
  • Hi2/20/2011

    If you don't want to add the program as a repository, you can just run it by the shell typing:
    ./name_of_program

To comment, please sign in to your Yahoo! account, or sign up for a new account.