如何找出哪个函数调用破坏了我的数据?

时间:2010-11-18 09:17:12

标签: delphi debugging

在Delphi 7中,

声明了一个类并从中创建了一个类(在uml中意为)。

该类包含一个公共字段类型的stringlist。

将对象传递几次后,第一行中的第一个字母就会被剔除。

我如何追踪它没有发生???

调用trims的函数是

stringlist.ValueFromIndex[i];

更多信息?

好吧,就像这样。

type 
  TObjectionFilterFields = class(TObject)
  private
    public
      z,x,c,v,b,n,a,s:integer;
      list1:TStringList;
      list2:TStringList;
      enum:TEnum;
      constructor Create; //override;
      destructor Destroy; //override;
  end;

现在在一个对象中,我们调用create,插入数据并传递它。 在另一个对象上,我们抓取数据并从中创建一个字符串,并且连接。

for i := 0 to list1.count-1
 sql.add(''''+list1.ValueFromIndex[i] + ''''+'hdsjkf');

envoking stringlist.Strings [i]解决了它

感谢

1 个答案:

答案 0 :(得分:1)

据我所知。您有一个包含TStringList类型的公共字段的对象。

type
  TMyClass = class
    FField : TStringList;
  end;

您已创建实例并将其传递给函数。

var
  instance : TMyClass;

begin
  instance := TMyClass.Create;
  try
    DoSomething(instance);
  finally
    instance.Free;
  end;
end;


procedure DoSomething(AObject: TMyClass);
begin
  // Check here
  DoSomethingElse(AObject);
  // Check here
end;

procedure DoSomethingElse(AObject: TMyClass);
begin
  // Check here
end;

您可以在每个函数的每个入口和出口点检查对象的状态,以便找出更改发生的时间。如果您自己找不到问题,请发布该代码。

请注意,使用公共字段可能很危险,因为任何内容都可以访问和更改该字段。