In Delphi 2010, I have a TreeView. The treeview has a data object defined as a record.
// Define the Data Object that will be associated with each Node
type
TNodeRec = record
rId: Integer;
rDate: TDateTime;
rSite: string;
rURL: string;
rRedirURL: string;
rTitle: string;
rCategory: String;
rURL_RtnCode: Integer;
rURL_RtnText: String
end;
I associate this data object with EACH node in the treeview, then I fill in the values. This works fine....
var
BuffData: ^TNodeRec; // The data object associated with each node;
URLNode: TTreeNode;
begin
...
// Create our New Data Object
new(BuffData);
BuffData^.rId := 0;
BuffData^.rDate := EDate;
BuffData^.rURL := ElString;
BuffData^.rRedirURL := '';
BuffData^.rTitle := ElText;
URLNode := TV1.Items.AddChildObject(nil, BuffData^.rTitle, BuffData);
My challenge is that from a buttonClick event, I need to pass this data object to another routine (in another UNIT) to modify it, and have the modified values available to the calling routine... This would normally be done via a VAR declaration, but I don't know that I need that, since I have declared this as a POINTER to a record.
Anyway, my ButtonClick event looks like this...
procedure TURLListForm.btnEvalSelectedClick(Sender: TObject);
var
SelNode : TTreeNode;
BuffData : TNodeRec;
begin
// verify there is a node selected
...
BuffData := TNodeRec(TV1.Selected.Data^);
WebEvaluate(BuffData);
ShowMessage(TNodeRec(TV1.Selected.Data^).rRedirURL);
end;
The problem is that the ShowMessage box is always empty, aka rRedirURL is not getting passed back like it would as a VAR declaration.
WebEvaluate is defined as
procedure WebEvaluate(Data1: TNodeRec);
begin
TNodeRec(Data1).rRedirURL := 'Test value'
ShowMessage('In WebEvaluate Routine:' + Data1.rRedirURL);
end
Within the WebEvaluate routine, Data1.rRedirURL has a value assigned. When I get back to the calling routine, the value is lost. I believe it has to do with how I am passing the Data1 record, but I don't know how to correct it... What am I doing wrong?
Thanks