⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 个人写的一个简单的Delphi程序
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
   PElement = ^TElement;
   TElement = Record
      txt: String;
      next: PElement;
   end;

  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Label1: TLabel;
    Button5: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormDeactivate(Sender: TObject);
    procedure Button5Click(Sender: TObject);
  private
    { Private declarations }
    Anker: PElement;
    Aktuell :PElement;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;



implementation

{$R *.dfm}

(*____________________________________________________________________________*)
 procedure TForm1.Button1Click(Sender: TObject);
 var
   P1, P2: PElement;

   anzahl: integer;
   pzaehl: PElement;

  { T: TextFile;
   SP, STR1, STR2: String;
   a: byte; }
 begin
   new(P1);
   P1^.txt := Edit1.Text;
   P1^.next := NIL;
   if Anker = NIL then
      Anker := P1
   else begin
      P2 :=  Anker;
      while (p2^.next <>NIL) do P2 := P2^.next;
   //   P2^.next := P1;
   end;
   Aktuell := P1;

   Edit1.Text := '';
 {  anzahl := 0;
   pzaehl := anker;
   while pzaehl <> NIL do
      begin
         inc(anzahl);
         pzaehl := pzaehl^.next;
      end;
   Label1.Caption := InttoStr(anzahl);   }

 { SP:=' :';
  AssignFile(T, 'C:\Dokumente und Einstellungen\Zhao\Desktop\ausgabe.dat');
  if not(FileExists('C:\Dokumente und Einstellungen\Zhao\Desktop\ausgabe.dat')) then ReWrite(T)
  else Append(T);
  STR1:= aktuell.txt;
  a := byte(@aktuell);
  aktuell := addr(a);
  Writeln(T, STR1 + SP + STR2);
  CloseFile(T); }
 end;
(*____________________________________________________________________________*)
 procedure TForm1.Button2Click(Sender: TObject);
 var
   P: PElement;

   anzahl: integer;
   pzaehl: PElement;
 begin
   if aktuell = Anker
      then begin       (*ist es das erste Element in der Liste?*)
         Anker := aktuell^.next;
         Dispose(aktuell);
         aktuell := anker;
      end
      else begin (*sonst*)
         p := anker;
         while (p <> NIL) and (p^.next <> aktuell) do p := p^.next;
         p^.next := aktuell^.next;
         Dispose(aktuell);
         aktuell := p;
      end;

   anzahl := 0;
   pzaehl := anker;
   while pzaehl <> NIL do
      begin
         inc(anzahl);
         pzaehl := pzaehl^.next;
      end;
   Label1.Caption := InttoStr(anzahl);
   
 end;
(*____________________________________________________________________________*)
 procedure TForm1.Button3Click(Sender: TObject);
 begin
   if aktuell^.next <> NIL then aktuell := aktuell^.next;
   Edit1.Text := aktuell^.txt;
 end;
(*____________________________________________________________________________*)
 procedure TForm1.Button4Click(Sender: TObject);
 var
   p: PElement;
 begin
   p := Anker;
   while (p <> NIL) and (p^.next <> aktuell) do p := p^.next;
   if p <> NIL then aktuell := p;
   Edit1.Text := aktuell^.txt;
 end;
(*____________________________________________________________________________*)
 procedure TForm1.Button5Click(Sender: TObject);
 begin
   aktuell^.txt := Edit1.Text;
 end;
(*____________________________________________________________________________*)
 procedure TForm1.FormActivate(Sender: TObject);
 begin
   anker := NIL;
   aktuell := NIL;
 end;

 procedure TForm1.FormDeactivate(Sender: TObject);
 var
   p, p_n: PElement;
 begin
   p := anker;
   while p<> NIL do
   begin
      p_n := p^.next;
      Dispose(p);
      p := p_n;
   end;
 end;
(*____________________________________________________________________________*)

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -