Category : Files from Magazines
Archive   : V12N02.ZIP
Filename : NEWOBJTS.PAS

 
Output of file : NEWOBJTS.PAS contained in archive : V12N02.ZIP
PROGRAM NewObjTst;
USES NewObjByType,
{$IFDEF Windows}
WObjects,
WinCrt;
{$ELSE}
Objects;
{$ENDIF}

TYPE
PObj0 = ^TObj0;
TObj0 = OBJECT(TObject)
PROCEDURE Who; Virtual;
END;

PObj1 = ^TObj1;
TObj1 = OBJECT(TObj0)
PROCEDURE Who; Virtual;
END;

Dat2 = RECORD
iX, iY : Word;
END;
PObj2 = ^TObj2;
TObj2 = OBJECT(TObj0)
X, Y : Word;
CONSTRUCTOR Init(VAR D : Dat2);
PROCEDURE Who; Virtual;
END;


PROCEDURE TObj0.Who;
BEGIN
WriteLn('I am a TObj0.');
END;

PROCEDURE TObj1.Who;
BEGIN
WriteLn('I am a TObj1.');
END;

CONSTRUCTOR TObj2.Init(VAR D : Dat2);
BEGIN
TObj0.Init; X := D.iX; Y := D.iY;
END;

PROCEDURE TObj2.Who;
BEGIN
WriteLn('I am a TObj2 : ',X,', ',Y,'.');
END;

VAR
A : ARRAY[0..2] OF PObj0;
N : Word;
Dat : Dat2;
BEGIN
Dat.iX := 42; Dat.iY := $FFFF;
A[0] := PObj0(NewByType(TypeOf(TObj0), @TObj0.Init, N));
A[1] := PObj0(NewByType(TypeOf(TObj1), @TObj1.Init, N));
A[2] := PObj0(NewByType(TypeOf(TObj2), @TObj2.Init, Dat));
FOR N := 0 to 2 DO A[N]^.Who;
FOR N := 0 to 2 DO Dispose(A[N], Done);
END.


  3 Responses to “Category : Files from Magazines
Archive   : V12N02.ZIP
Filename : NEWOBJTS.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/