Basics on the Pascal Language

{This short demonstration is an example of what Pascal program usually looks like}
PROGRAM Welcome (Output);
USES CRT;

VAR
Number : INTEGER;

PROCEDURE WriteWords;
BEGIN ClrScr;
Number := 1 + 1;
WRITELN (Output, 'Hello Visitor!');
WRITELN (Output, 'That makes the ', Number, ' of us!');
READLN;
END;

BEGIN
WriteWords; END.
{The end. Now, that wasn't too hard wasn't it? ^_^}

This is what I write in class. The very basic stuff.
Pascal Programming is a "teaching" language, which means it helps you
understand concepts of programming.
The above "program" will display the following:

Hello Visitor!
That makes the 2 of us!




At the begining, you always type the reserved word PROGRAM and then
the name of your program. The (Output) thingy after that, is technically called the
parameter. Sometimes the program is so simple that you don't even need to type it.
";" indicates the end of the command line.
The next line is to locate the Source File which you get the Functions from.
In this case, it's a file named CRT. Other times it can be GRAPH or DOS, etc.
The next section is the Variable List(s).
Here is where the Global Variables are listed and declared. The words might
sounds complicated, but as you get to know them more, you'll see that they are common
terms. In this program, there is only one variable and I named it "Number". It will only
have INTEGER values, which is what's written after it.
Then comes the PROCEDURE command, which is/are the divided section(s) of
the program. It is not necessary if the program is short, but it's really helpful when you
have tons of repeated codings. Name it something "Unique". Every BEGIN comes with
an END "of its own". You'll see what I mean when you start programming.
- "ClrScr" is a function in CRT, which means "Clear the Screen".
- I assign the value of 1+1 to the variable Number. So Number now equals 2.
- "WRITELN" is a function too, which will write out whatever is in '. In this case
it will write out "Hello Visitor!" in the first line.
- After that I tell it to write "That makes the ", then the value of Number, and
" of us!" at the second line.
- The next line means that you have to press Enter to allow the program to proceed.
- This Procedure ends here.
The BEGIN of the main program. In this case there is only one command, which is
the short procedure I've made "before" it. End the program with a period rather than ";".
That's it. Oh, and, whatever is written in "{" is comments, which will not effect the
program.

Back to Main
1