R
R
retyui2015-06-09 10:03:29
Delphi
retyui, 2015-06-09 10:03:29

Delphi end of string after conversion?

This is how I attach data to TTreeNode ,

node := tv1.Items.Add(nil,qry1.FieldByName('title').AsString);
node.Data:=Pointer(string(filePath+qry1.FieldByName('file').AsString));

And this is how I pull it out:
procedure TFormGlobal.tv1Change(Sender: TObject; Node: TTreeNode);
var     file__,PATH__:String;
  begin

    if Assigned(Node) then begin
      file__:= string(Node.Data); /////////<-

As a result, I have a broken line with the last character
4e5d1f88392647f5b04b333bdc150fed.PNG
should be at the end .../kniga_2.do c

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rediskus, 2015-06-09
@retyui

Those. the line is created in one procedure, and pulled out in another? And who will allocate memory, free it? It's strange that it works at all.
Wish it was so

procedure TForm13.Button1Click(Sender: TObject);
var
 n:TListItem;
 s:^String;
begin
 n:=ListView1.Items.Add;
 n.Caption:='test node';
 New(s);
 s^:='test test test';
 n.Data:=s;
end;

but to get
if n.Data<>nil then
  begin
   s:=n.Data;
   ShowMessage(s^);
   Dispose(s);
  end;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question