type
TPChar = ^char;
TPCell2 = ^TCell2; { Forward reference }
TCell2 = record
Ch : char;
Prev, Next : TPCell2
end;
var
TopL, BottomL : TPCell2;
procedure AddCell(var Top,Bottom:TPCell2; NewCh:char);
var NewCell:TPCell2;
begin
New(NewCell);
with NewCell^ do
begin
Ch := NewCh;
Next := Top;
Prev := nil
end;
if Top <> nil then
Top^.Prev := NewCell
else
Bottom := NewCell;
Top := NewCell
end;
procedure DeleteCell(var Top,Bottom:TPCell2);
var NewTop:TPCell2;
begin
if Top <> nil then
begin
NewTop := Top^.Next;
Dispose(Top);
Top := NewTop;
if (Top = nil) then
Bottom := nil
end
end;
procedure Fourth(const D:TPChar; E:TPChar; var F:char);
begin
D^ := 'd';
E^ := 'e';
F := 'f'
end;
procedure TForm1.Button1Click(Sender: TObject);
var MyD, MyE, MyF : char;
begin
Fourth(@MyD,@MyE,MyF);
edit1.text := MyD+MyE+MyF
end;
procedure TForm1.Button2Click(Sender: TObject);
var ch : char;
begin
ch := edit2.text[1];
AddCell(TopL,BottomL,ch);
edit2.text := chr(ord(edit2.text[1])+1);
edit3.text := ch
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if TopL=nil then
edit3.text := 'Already Nil'
else
begin
DeleteCell(TopL,BottomL);
if TopL=nil then
edit3.text := 'Nil'
else
edit3.text := TopL^.Ch
end
end;
initialization
TopL := nil;
BottomL := nil
end.