帮我看一下,问题在哪里?(Dynamic Array问题)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TValue = Record
str1: string;
Int: integer;
str2: string;
str3: string;
End;
PValue = ^TValue;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
List: TList;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
i, j: integer;
TreeNode, ValueNode: TTreeNode;
ArrayValue: Array Of PValue;
begin
SetLength(ArrayValue,4);
For i := 0 To 4 Do
Begin
GetMem(ArrayValue[i],SizeOf(PValue));
ArrayValue[i]^.str1 := 'aaa';
ArrayValue[i]^.str2 := 'bbb';//在这里出错,帮帮我查一下为什么?谢谢!
ArrayValue[i]^.str3 := 'ccc';
End;
IF Assigned(List) Then List.Destroy;
IF Not Assigned(ArrayValue) Then Raise Exception.Create('Null of ArrayValue');
List := TList.Create;
List.Add(ArrayValue);
ShowMessage('The ArrayValue has Add into List Item');
end;
end.
帮帮我查一下为什么?谢谢!