Dec 232017
 
This TP 5.5+ unit builds on the OBJECTS.PAS file on disk three of the TP package. The OBJECTA unit offers a decendent which adds links before and after.
File OBJA.ZIP from The Programmer’s Corner in
Category Pascal Source Code
This TP 5.5+ unit builds on the OBJECTS.PAS file on disk three of the TP package. The OBJECTA unit offers a decendent which adds links before and after.
File Name File Size Zip Size Zip Type
OBJECTA.DOC 3082 1229 deflated
OBJECTA.PAS 5709 1730 deflated

Download File OBJA.ZIP Here

Contents of the OBJECTA.DOC file





OBJECTA

A TP 5.5 OOP UNIT

Rob Rosenberger CIS: 74017,1344
Barn Owl Software VOX: (618) 632-7345
P.O. Box #74 BBS: (618) 398-5703
O'Fallon, IL 62269 HST: (618) 398-2305

This Turbo Pascal 5.5 unit builds on the OBJECTS.PAS file on
disk three of the TP package. The Objects unit provides some
excellent linked-list capabilities, but it doesn't allow arbi-
trary placement of a node on the list. The OBJECTA unit offers a
decendent, LinkList, which provides two methods: LinkList.Before,
to place a node just before some other node in the list, and
LinkList.After, to place a node just after some other node in the
list.

LinkList.Init and LinkList.Done are included because the TP
5.5 OOP guide recommends these common procedures. The List
ancestor calls them Clear and Delete, respectively, which I found
extremely odd since Borland is the one calling for a standard set
of method identifiers....

Version 1.00: released to the public domain on 8 July 1989.

Version 1.01: released to the public domain on 17 August 1989.
Lavern Ogden discovered an endless loop in the Total()
function. This was due to my using LinkList.Next instead of
LinkList.Next(). I fault Borland for this error -- there are two
"Next" possibilities. Shame shame!
Added a new function, Specific(), which returns a NodePtr to
the nth node in the list. This will be very handy for people who
use TurboPower Software's TPPICK unit from their TPRO5 toolkit.


TYPE
LinkList
= OBJECT(List)
PROCEDURE Init;
PROCEDURE Done;

PROCEDURE Before(TheNode : NodePtr;
BeforeNode : NodePtr);
PROCEDURE After (TheNode : NodePtr;
AfterNode : NodePtr);

FUNCTION Specific(NodePos : LONGINT) : NodePtr;
FUNCTION Total(TheNode : NodePtr) : LONGINT;
END;



PROCEDURE LinkList.Init;

This procedure initializes the LinkList.


PROCEDURE LinkList.Done;

This procedure deletes all nodes from the list.


PROCEDURE LinkList.Before(TheNode : NodePtr;
BeforeNode : NodePtr);

Places TheNode in the LinkList just before BeforeNode.


PROCEDURE LinkList.After(TheNode : NodePtr;
AfterNode : NodePtr);

Places TheNode in the LinkList just after AfterNode.


FUNCTION LinkList.Specific(NodePos : LONGINT) : NodePtr;

Returns the NodePtr to the nth node in the list, represented
by NodePos. The returned value will be NIL if NodePos <= 0, or
if it is > Total.


FUNCTION LinkList.Total(TheNode : NodePtr) : LONGINT;

This function returns a number corresponding to the number
of nodes on the LinkList. It starts counting from TheNode^.
Therefore, to get a total count of all nodes on the LinkList, use
LinkListVar.Total(LinkListVar.First). (Remember, we inherit the
"First" function due to OOP.)


 December 23, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)