Hi jason,
Here's one 1st sample of OO-code:
Program 1st_object;
uses crt;
type
{ that's called defining the oject foo }
foo=object
{data}
name:sting; {==> all in one single structure }
age :byte;
{algoritmes}
procedure WriteName;
procedure WriteAge;
end;
{ here follows what we call the declaration of the object }
{ actually it's just specifying what any procedure will do when called }
{ just like any code you write.for an oject procedures and functions are}
{ called 'methods'.pay attention to the special syntax though.
{ procedure (or function)+ dot(.)+the name of the procedure(or functiun)}
procedure foo.WriteName;
begin
writeln('your name is : ',foo.name);
end;
procedure foo.WriteAge;
begin
writeln('your age is : ',foo.age,' years');
end;
{ instead of writing foo.name/foo.age,name or age would have closed the deal.}
{ the compiler would have considered that those items as foo's corrrespondig }
{ ones on a default basis.}
{ main prg }
{ declaring a foo type variable.in object terminology that's called }
{ ~instanciating~ foo }
var instance:foo;
begin
clrsccr;
{ initialize the variables }
instance.name:='Jason';
instance.age:=8; { this im not sure! }
instance.writeName;
instance.WriteAge;
end.
Now here's another one using what is called ~inheritance~(simple inheritance
actually for multiple inheritnce does not exist in pascal yet.
say we create an oject Bar for instance(im mean for example,not an object
instance ;-) ) say again this one object needs to do the same things as the foo
object with an additionnal feature:display your surname.this how it's done in
pascal:
Program 2nd_object;
uses crt;
type
{ foo definition }
foo=object
name:sting;
age :byte;
procedure WriteName;
procedure WriteAge;
end;
{ bar definition }
bar=object(foo) { here's the new trick !}
surname :string;
procedure WriteSurname;
end;
{ the good old foo declaration...}
procedure foo.WriteName;
begin
writeln('your name is : ',name);
end;
procedure foo.WriteAge;
begin
writeln('your age is : ',age,' years');
end;
{ now this particular routine of bar...}
procedure bar.WriteSurname;
begin
writeln('your surname is : ',surname,);
end; { no big deal! }
{ main prg }
{ instanciating bar }
var instance:bar;
begin
clrscr;
{ initialize the variables }
instance.name:='Jason';
instance.age:=8;
instance.surname:='Young';
instance.writeName;
instance.WriteAge;
instance.WriteSurname;
end.
OK jason! that's will be about all for today.when you're done w/ this let me
know so we can procceed w/ something else if you wish.
i'll be looking into something interesting about TP7 on the net for ya.
Bamba Ismael
real life @:32,rue de bouret-75019 Paris,France
CU soon.(:-D)