Implementing a Last In First Off (LIFO) stack using a linked list... http://www.awitness.org/delphi_pascal_tutorial/source/LIFO_stack_linked_list.html type link=^node; {last on first off undo linked list stack} node=record i:integer; nextlink:link end; var head, temp:link; The head should be initialized to point to 'nothing' (nil). If you are using a form then setting the head to nil in the FormCreate procedure would be a good idea. head:=nil; procedure TForm1.LIFOPush(c:integer); { new(undohead); undohead^.unextlink:=nil; } begin new(temp); temp^.i:=c; temp^.nextlink:=head; head:=temp; end; Note that if you have more than one LIFO stack then you can include a second variable in the procedure call including the value of the head pointer for the stack you want to reference. procedure TForm1.LIFOPush(c:integer; head:link); The function to pop an item off the LIFO stack would take the following form. You can call the function with the head pointer to the LIFO stack. In this example the function will return the value of the integer popped off the stack. function LIFOPop(head:link):integer; result:=head^.i; temp:=head; head:=head^.nextlink; Dispose(temp); end;