Here's the basic structure of a TP7 program.


This program will simply clear your screen and write Hello World

program helloworld;
uses crt;

const

var

function nothing1:integer;
begin
end;

procedure nothing;
begin
nothing1;
end;

begin
clrscr;
writeln('Hello World');
nothing;
end.

Every program in TP7 must start with the line:
program nameofprogram;
Every statement on TP7 must end with a semi-colon.
After the first line comes a line where you indicate what "languages" you want your program to use.
The most basic one is "crt" but if you want to work with graphics you'll have to use "graph" ( there are lots of other ones such as "wincrt" but I haven't learnt how to use them yet ).
Then you can list some constants but this is optional ( I didn't need any in this program since it's so simple, but in more complex programs, constants can come in handy ).
Under the "const" you can list values which will never change throughout the program ( such as X=200 ).
Then you can list some variables but this to is optional ( I didn't need any in this program since it's so simple, but in more complex programs, variables can come in handy ).
Under the "var" you can list values which will change troughout the program so you don't fix definitive values under the var.
For example: X:integer ( see TP7 definitions ).
Once you've done that you can insert "functions" and "procedures".
These allow you to group a set of statements into one single block.
Functions ( sort of sub-procedures ) are very similar to procedures but they do have a slight difference, they have to be of a certain type ( in this case of type integer, however this can change, there are some boolean functions, etc. )
As you can see, the function nothing1 was called in the procedure nothing so it has to be placed befor the procedure nothing.
"Nothing1" and "nothing" don't do anything since they have been given no statements.
These should be inserted between the "begin" and "end".
For example, if you wanted the procedure nothing to write "hello" it would look like this:
procedure nothing
begin
writeln('hello');
end;
Now stats the main procedure. The main procedure is not all that different from a normal procedure except it is not optional and doesn't end with a ";" but with a ".".
The clrscr is just a statement that tells the computer to clear the screen ( it requires crt ).
The writeln is a statement that tells the computer to write something on the screen. These two statements will be reviewed in TP7 definitions .

This is the basic ( very basic ) structure of a TP7 program.







This page hosted by GeoCities Get your own Free Home Page


1