unit ZettelkastenU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
PStapel = ^TZettel;
TZettel =
record
Inhalt:
string;
next: PStapel;
end;
TForm1 =
class(TForm)
Bpop: TButton;
Bpush: TButton;
Memo1: TMemo;
StaticText1: TStaticText;
B_alleNotizen: TButton;
procedure FormCreate(Sender: TObject);
procedure BpushClick(Sender: TObject);
procedure BpopClick(Sender: TObject);
procedure B_alleNotizenClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Stapel:PStapel;
i:integer;
implementation
uses NotizfensterU;
{$R *.dfm}
procedure push(
var Stapel:PStapel;Neuinhalt:
string);
var
Neuknoten:PStapel;
begin
New(Neuknoten);
Neuknoten^.Inhalt := Neuinhalt;
Neuknoten^.Next := Stapel;
Stapel := Neuknoten;
end;
procedure pop(
var Stapel:PStapel;
var AInhalt:
string);
var
Hilf:PStapel;
begin
Hilf := Stapel;
Stapel := Stapel^.Next;
AInhalt := Hilf^.Inhalt;
dispose(Hilf);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
New(Stapel);
i:= 1;
end;
procedure TForm1.BpushClick(Sender: TObject);
begin
push(Stapel,Memo1.Lines.GetText);
Memo1.Clear;
Memo1.SetFocus;
inc(i);
Form1.Caption:= ('
Notizen: ' + IntToStr(i));
end;
procedure TForm1.BpopClick(Sender: TObject);
var
temp:
string;
begin
if i > 1
then
begin
pop(Stapel,temp);
Memo1.Clear;
Memo1.Lines.Add (temp);
i:= i-1;
Form1.Caption:= ('
Notizen: ' + IntToStr(i));
end;
end;
procedure TForm1.B_alleNotizenClick(Sender: TObject);
var
cache1,cache2:PStapel;
c:integer;
begin
// Form2.Memo1.clear;
Form2.ShowModal;
c:= i;
cache1:=Stapel;
while c>0
do
begin
cache2:= cache1;
Form2.Memo1.Lines.Add(cache1.Inhalt);
Form2.Memo1.Lines.Add('
---');
cache1:= cache2.next;
c:= c-1;
end;
end;
end.