none
none

Reputation: 4827

How can I find out which function call is corrupting my data?

in Delphi 7 , declared an class and created a class from it, (in the uml meaning).

the class contains a public field type of stringlist.

after passing the object a few times, the first letter in the first row is trimed out.

how do i trace it from not happening???

the function calling that trims is

stringlist.ValueFromIndex[i];

more information?

well its something like this.

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;

now at one object we invoke create, and insert data, and pass it on. on another object we grab the data and create a string out of it, with + concatination.

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

envoking stringlist.Strings[i] solved it

thanks

Upvotes: 0

Views: 190

Answers (1)

Toon Krijthe
Toon Krijthe

Reputation: 53366

As far as I can understand. You have an object that contains a public field of the type TStringList.

type
  TMyClass = class
    FField : TStringList;
  end;

You have created an instance and passed it to a function.

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;

You can check the state of the object at each entry and exit point of each function so you find out when the change occurs. Post that code if you cannot find the problem yourself.

Please note that using public fields can be dangerous, because anything can access and change that field.

Upvotes: 1

Related Questions