Delphi E2029:需要声明但找到文件结尾 - 如何调试?

Delphi E2029: Declaration expected but end of file found - how to debug?

大家好,我出现了一个错误,我无法摆脱它..

我在我的 delphi 代码中添加了 2 个自定义过程,我读到您可以点击 crtl+shift+c 来自动生成这些函数,我做到了。

但是我现在的问题是我不需要自动生成的东西,这就是为什么我在执行命令后将其删除的原因。现在我的代码不再工作,因为我得到这个错误:

E2029 Declaration expected but end of file found

Expected INITIALIZATION but recieved the end of file at line 520(520:1)

如何修复我的代码?在文件末尾删除或添加 'end' 对我没有帮助。有没有办法找出我的代码中缺少的地方? (我可以 post 我的 delphi 代码,但它的 500 行长我认为没有意义。

更新代码:

unit Benutzerverwaltung_U;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.ComCtrls,
  Vcl.StdCtrls,
  Vcl.WinXCtrls, Vcl.CheckLst, System.Actions, Vcl.ActnList, Vcl.Menus,
  System.StrUtils,
  Data.DB, Vcl.Grids, Vcl.DBGrids, Vcl.DBCtrls, FireDAC.Stan.Intf,
  FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS,
  FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Comp.DataSet,
  FireDAC.Comp.Client;

type
  TForm1 = class(TForm)

other buttons and so on...

    procedure SwapValues(var Zahl1, Zahl2: Integer); //new
    procedure SelectionSort(Sender: TObject);  // new
    procedure Button11Click(Sender: TObject); //new

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }

    workerModel: record
      VorName: string[40];
      NachName: string[40];
      Age: Integer;
      Schließen: string[30];
      Admin: TToggleSwitchState;
      DatenSehen: TToggleSwitchState;
      Gender: string[20];

    end;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Sonderrechte_U, CheckedItem_U, Unit1, BenutzerEdit_u;


procedure TForm1.SwapValues(var Zahl1, Zahl2: Integer);
var
  h: Integer;
begin
  h := Zahl1;
  Zahl1 := Zahl2;
  Zahl2 := h;
end;

procedure TForm1.SelectionSort(Sender: TObject);
var
  i, j, min: Integer;
var
  sortArray, Data: Array of string;

begin

  for i := 1 to Form1.ListBox1.Items.Count - 1 do
  // i muss wahrscheinlich 0 sein?
  begin
    min := i;
    for j := i + 1 to Form1.ListBox1.Items.Count do
      if (Data[j] < Data[min]) then
        min := j;
    SwapValues(i, min);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2 := TForm2.Create(Self);
  try
    Form2.ShowModal;
  finally
    Form2.Free;
  end;

end;

// more code

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  l: Integer;
  t: String;
begin
  with ListBox1 do
  begin
    Canvas.FillRect(Rect);
    t := Items[Index];
    l := Rect.Right - Canvas.TextWidth(t) - 1;
    Canvas.TextOut(l, Rect.Top, t);
  end;
end;

procedure TForm1.SearchBox1Change(Sender: TObject);

var
  i: Integer;

begin
  // SearchBox1.Parent := ListBox1;

  ListBox1.Items.BeginUpdate;

  try
    for i := 0 to ListBox1.Items.Count - 1 do
      ListBox1.Selected[i] := ContainsText(ListBox1.Items[i], SearchBox1.Text);

  finally
    ListBox1.Items.EndUpdate;


end;
// end;


// this is the end of the file

一个Delphi单元必须以

结尾
end.

(注意句号)。