PDA

View Full Version : My helloworld program doesn't compile



Polar
19-08-2009, 12:42 PM
I'm new to Pascal and I'm learning it using the Free Pascal compiler. I thought of starting with a helloworld program so I wrote this program:

Program helloworld ;

Begin

writeln ('Hello World') ;
readln ;

End.

The program compiled with no problems. Then I thought of adding a variable so I wrote this program:

Program helloworld ;

var

x : integer ;

Begin

x := 1 ;

writeln ('Hello World') ;
readln ;

End.

The program didn't compile and I got an error message. I don't understand why I simply added a variable. What should I do exactly?

AthenaOfDelphi
19-08-2009, 01:20 PM
Well, first up, welcome to PGD Polar.

I'm no FreePascal expert, having never used it, but what you've got is pretty standard Pascal so I should be able to help... unfortunately, I can't because I can't see anything wrong with the code.

So, is it an error you're getting or is it a warning... possibly something like 'The value assigned to X is not used'?

Whatever, we will need more information, mainly the exact messages returned by the compiler if we are to help you.

arthurprs
19-08-2009, 04:38 PM
what's the error message?

Polar
19-08-2009, 05:59 PM
The error message says: Compile failed. Also it tells me that there are 2 errors. I don't get it my code doesn't seem to have errors.

pjpdev
19-08-2009, 06:12 PM
Welcome to PGD Polar... I only use FreePascal and might be able to help. Though going through you're code I don't see anything wrong. Like Athena said, it's basic pascal. Please tell us what error messages did the compiler return.

Legolas
19-08-2009, 07:00 PM
It could be useful to tell us some other infos, e.g. your fpc version, your OS and so on. Another tip is to compile with

fpc -va helloworld.pas > out.txt

and to put somewhere the file out.txt.

Polar
21-08-2009, 08:31 AM
Oops! it seems that I deleted one of the ; symbols by mistake before compiling. I've added it again and now the program compiles with no problems. Thank everybody for your friendly responses and hopefully now I can make some progress in learning Pascal.