{ Procedure to add items into the list }
Procedure AddItem (Newvalue: Integer);
Begin
{Check If this is the first time the structure is going to be created}
If Current = NIL Then
Begin
New(Current); {Get memory for the data}
With Current^ do {Fill in the data}
Begin
Value:=NewValue;
NextItem:=NIL; {Since there are any more Up this points NIL}
PrevItem:=NIL {Since there are any more Down this points NIL}
End;
Start:=Current;
Finish:=Current
End
Else {Now this is not the first time}
Begin
New(Finish);
Finish^.PrevItem:=Current; {Current <- Finish}
Finish^.NextItem:=NIL; {Finish -> Nil}
Current^.NextItem:=Finish; {Current -> Finish}
Current:=Finish; {Current:=Finish}
With Current^ do {Fill in the data}
Begin
Value:=NewValue;
End
End
End;