Class TForm1 (unit linklist)

Inherits from

TForm

Constructors



Functions

procedure BtnAddClick(Sender: TObject);

this procedure will add a new record to the linked-list.

procedure BtnDeleteClick(Sender: TObject);

This procedure will delete a record from our linked-list.

procedure BtnExitClick(Sender: TObject);

this procedure is a little obvious :-)

procedure BtnNextClick(Sender: TObject);

this procedure will move backwards through the list by stringing along the 'Next' pointers in the records.

procedure BtnPrevClick(Sender: TObject);

this procedure will move backwards through the list by stringing along the 'Prev' pointers in the records.

procedure EdIntegerChange(Sender: TObject);

This procedure will update the data stored in our record as it is changed

procedure EdStringChange(Sender: TObject);

This procedure will update the data stored in our record as it is changed

procedure FormCreate(Sender: TObject);

all this procedure will do is setup some default values for our pointers

function AddrToStr(var Address: Pointer): String;

This function returns a string representing the Hexadecimal address of the "Address" pointer passed as a parameter

procedure AddToList(var CompAnchor: PComp);

This procedure adds new records to the linked-list.

procedure UpdateDisplay(var Ptr: PComp);

This function is not really important, it merely shows visually what is going on with the linked-list

Properties

Events

Variables

BtnAdd : TBitBtn;


BtnDelete : TBitBtn;


BtnExit : TBitBtn;


BtnNext : TBitBtn;


BtnPrev : TBitBtn;


EdAddress : TEdit;


EdInteger : TEdit;


EdItemNum : TEdit;


EdNext : TEdit;


EdPrev : TEdit;


EdString : TEdit;


Label1 : TLabel;


Label2 : TLabel;


Label3 : TLabel;


Label4 : TLabel;


Label5 : TLabel;


Label6 : TLabel;


Label7 : TLabel;


LblItems : TLabel;


Panel1 : TPanel;


FCompAnchor : PComp;

Private declarations

FCompCurrent : PComp;


FItems : integer;



Constructors


Functions


procedure BtnAddClick(Sender: TObject);

this procedure will add a new record to the linked-list.


procedure BtnDeleteClick(Sender: TObject);

This procedure will delete a record from our linked-list. The way this works is a little tricky until... first we check to see if our current pointer has a Prev ptr. If it does we then check to see if it has a Next ptr. If it does we set the Prev ptr's Next ptr to the Current ptr's Next ptr. Got that? :-) Otherwise we set the Prev ptr to nil. Then we do the same sort of check regarding the Next ptr vs. the Prev ptr so we can assign the Next ptr's Prev ptr to the Current ptr's Prev ptr... got that? Basically what we're doing is setting up to remove the Current record by assigning its Prev and Next ptr's to the records ahead and behind the Current record. Of course if there is no more records on one side or the other we set that side to nil. Once the pointers have been rearranged we're free to simply dispose of the Current pointer. Remember though that if your record contains OTHER pointers that have been allocated they need to be disposed of FIRST before you get rid of the Current Pointer!!!! Our example record does not have any of these so we don't have to worry about it


procedure BtnExitClick(Sender: TObject);

this procedure is a little obvious :-)


procedure BtnNextClick(Sender: TObject);

this procedure will move backwards through the list by stringing along the 'Next' pointers in the records. This of course can only go on until we get to the last record which will not have a Next pointer assigned


procedure BtnPrevClick(Sender: TObject);

this procedure will move backwards through the list by stringing along the 'Prev' pointers in the records. This of course can only go on until we get to the first record which will not have a Prev pointer assigned


procedure EdIntegerChange(Sender: TObject);

This procedure will update the data stored in our record as it is changed


procedure EdStringChange(Sender: TObject);

This procedure will update the data stored in our record as it is changed


procedure FormCreate(Sender: TObject);

all this procedure will do is setup some default values for our pointers


function AddrToStr(var Address: Pointer): String;

This function returns a string representing the Hexadecimal address of the "Address" pointer passed as a parameter


procedure AddToList(var CompAnchor: PComp);

This procedure adds new records to the linked-list. This is the central point of the linked-list management. If the list does not already exist the add procedure creates it. The 'CompAnchor' parameter passed is a pointer to the first element in the linked-list. This element will never change unless the list is entirely deleted.


procedure UpdateDisplay(var Ptr: PComp);

This function is not really important, it merely shows visually what is going on with the linked-list


Properties


Events


Variables


BtnAdd : TBitBtn;


BtnDelete : TBitBtn;


BtnExit : TBitBtn;


BtnNext : TBitBtn;


BtnPrev : TBitBtn;


EdAddress : TEdit;


EdInteger : TEdit;


EdItemNum : TEdit;


EdNext : TEdit;


EdPrev : TEdit;


EdString : TEdit;


Label1 : TLabel;


Label2 : TLabel;


Label3 : TLabel;


Label4 : TLabel;


Label5 : TLabel;


Label6 : TLabel;


Label7 : TLabel;


LblItems : TLabel;


Panel1 : TPanel;


FCompAnchor : PComp;

Private declarations


FCompCurrent : PComp;


FItems : integer;