Setting up a Pascal Compiler on your home computer

Document Sample
Setting up a Pascal Compiler on your home computer Powered By Docstoc
					Setting up a Pascal Compiler on your home computer:

To run Pascal programs on your computer you need to
have a Pascal compiler installed on it. There are many free
Pascal compilers available on the internet. Two most
popular Pascal compilers are ‘Dev+GNU Pascal’ compiler
and ‘Free Pascal’ complier.

 On the computers in the pc lab at UHCL we have
‘Dev+GNU Pascal 1.9.2’. You can download the same for
free from

http://www.bloodshed.net/dev/devpas192.exe

Else, if you prefer ‘Free Pascal’, you can download it for
free from

http://prdownloads.sourceforge.net/freepascal/fpc-
2.0.2.i386-win32.exe?download

Download any one of the above and install it.



How to use Dev+GNU Pascal:

Once you download and install Dev+GNU Pascal on your
computer, it should show up in the list of all the programs
on your computer.

Go to: ‘Start  All Programs  Dev+GNU Pascal 1.9.2 
The Dev+GNU Pascal IDE’
It looks like:
Go to: ‘File  New Source File’ (or simply click Ctrl + U)
The result would look like this:




Clear all the text in there and type your program.
For Example, the following screenshot shows the program
to print ‘Hello World’
Now, save your file.
Go to: ‘File  Save Unit’ (or simply click Ctrl + S)




Save it to wherever the location you want.
In the following screenshot, the file is being saved to the
Desktop with the file name Untitled1.pas (.pas stands for
a Pascal source file!)
So your Pascal source file is now saved on to the Desktop.




So now, you got to execute (Compile and Run) that file
(your program)

To compile and run your program, go to ‘Execute 
Compile and Run’ (or Click ctrl + F10)
If your program is correct, then the result will be displayed




Also, note that the executable file ‘Untitled1.exe’ (.exe
stands for executable file) now appears on the desktop!
(the place where we already stored our source file
‘Untitled1.pas’)




Just double click on that any time and it would display
the result of your program in the source file ‘Untitled1.pas’
If anything is wrong with the program, the errors would be
displayed for you to correct.

For example, let’s go back to our ‘Hello World’ program.
The correct code for the program is

program Hello;
begin
writeln('Hello World');
readln
end.

Let’s deliberately make some syntactical errors to see what
would happen. We all know a ‘writeln’ statement should
end with a semicolon. Let’s remove the semicolon and try
to compile and run the program.

program Hello;
begin
writeln('Hello World')
readln
end.
The program should NOT run since erroneous compile
results are expected. The same thing happens and the
errors are shown!




By looking at what has gone wrong, you may correct your
program and be able to compile and run successfully!

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:13
posted:5/13/2011
language:English
pages:9