Home Documentation Wiki Downloads Screenshots


Documentation


Table of contents

1. Installation
2. Getting Started ("Hello, World!" á la gPascal)
3. Common Errors

1. Installation TOC

Installation on GNU/Linux is quite simple if you are using debian or an debian based distribution.
First of all you need to install gpc. You do that by executing

apt-get install gpc

as root in a terminal. Then you download one of the debian packages from this site and install it as follows:

dpkg -i path_to_the_package

Then you can start it by typing gpascal in a terminal. Starting gPascal from a terminal
is recommended because you cant see the compilers output or your compiled application otherwise.

On the other GNU/Linux distros, you also have to install gpc and the GTK+ development headers at first.
The GTK+ development headers are usually called libgtk2.0-dev
When done, unpack the source package you downloaded from this page
Switch to a terminal and cd into the folder where the unpacked files are.
Then, execute the following commands:

1. ./autogen
2. make
3. make install

Now gPascal is installed and you can run it by typing gpascal in a terminal, just like shown above.


Installation on Windows works as follows:

1. Download the Binary Installer
2. Unpack it and/or run the file called gpascal_x.xx_win32_setup.exe
3. Follow the installation steps (GTK+ and the GPC will be installed as well)
4. Run gPascal from the Start Menu


2. Getting Started TOC

This is a small tutorial for writing an "Hello, World!"-application in pascal using gPascal.

First of all, when running GNU/Linux, open a terminal and execute the command gpascal.
When running Windows, simply run gPascal from the start menu.

Now you will see the gPascal Main Window. It shows a simple editor with buttons for loading and saving
source, as well as compiling and running it. So, in order to create a new source file, press the
New button and choose the location where you want the source to be saved. For instance,
navigate to C: under Windows, or to your home directory when using GNU/Linux.
Now you can type the name of the file to be created in the text entry, hardly at the bottom of the window.

Remember: The filename should always end in .pas in order for the compiler to work correctly!

When you have pressed Okay, you should have noticed, that the window's title changed, and
That a TextView has appeared. In it, you can now write the source.

To create a really simple "Hello, World!", enter the following in there:

PROGRAM helloworld;

BEGIN

writeln('Hello, World!');

END.


Now, for explaining the code:

Every program begins with a line like PROGRAM program_name;
It has no real effect on the code, however it has to be present.

The next line is BEGIN
It indicates when a function or procedure starts. In this case, its the start of the main procedure.

The following line is writeln('Hello, World!');. As you might already have guessed, writeln prints
a line onto the screen. There are two different ways to print things to the screen:

1. write
2. writeln

The're is only one difference between the both commands:
write doesnt finish the line, while writeln does.

To explain this:

write('Blah ');
write('Blah');

would look like this:

Blah Blah

While

writeln('Blah');
writeln('Blah');

Would look like this:

Blah
Blah

Now, to the next line, END.
It means, that the main procedure ends. END is used, whenever a procedure is finished.
But, Remember: The main procedure always ends with END. while all other procedures end with END; !

So far for the programming part. Now let's take a look on how to run that file.

When done writing the code, always remember to press on the Save button. Else the compiler will not
compile the most recent code, but the code what you saved last.

Now, to run the example shown above, you would simply click on Save and after that on Compile & Run.
After you clicked the button, the code will be compiled and instantly executed.

This means, if everything worked well, the console should show some output like this:

Compiling /home/linuxx/helloworld.pas:
gpc /home/linuxx/helloworld.pas

Running compiled File:

---- START ----

Hello, World!

---- END ----

If you get some compiler error, make sure you have exactly the code as shown above and you did press on Save before compiling.

Note: Either way, compiling via Compile or Compile & Run an executable file is created: Its location is exactly
the same, as the source is located. So, when using GNU/Linux, it should be called a.out, or when using Windows, it is a.exe.

3. Common Errors TOC

1. Error:

path_to_source/filename.pas:1: error: empty input file

Solution:

It looks like you have either forgotten to save before compiling, or did not write any source at all.
Always save before compiling.

Copyright (C) 2007 - The gPascal Team
Valid XHTML 1.0 Transitional Valid CSS! Content Enhanced - Use Any Browser SourceForge.net