U
units
Unregistered / Unconfirmed
GUEST, unregistred user!
如题,要求做成一个函数,返回值为动态字符数组,遍历的程序我有了,可当我尝试加上
存储动态数组的功能时总是有些问题,源程序如下,请大侠指教!!
-----------------
TSubNodeText = array of string;
function GetAllSubNode(SelNode: TTreeNode): TSubNodeText;
var
ChildNode, TempNode:TTreeNode;
SubNodeText: TSubNodeText;
begin
ChildNode := SelNode.getFirstChild;
while ChildNode <> nildo
//找到第一个子节点了
begin
SetLength(SubNodeText,Length(SubNodeText)+1);
SubNodeText[High(SubNodeText)] := ChildNode.Text;//添加Node的Text到字符数组
TempNode := ChildNode.getFirstChild;
if TempNode <> nil then
//如果还有子节点,则递归
begin
GetAllSubNode(ChildNode);
end;
TempNode := ChildNode;
ChildNode := SelNode.GetNextChild(TempNode);
end;
Result := SubNodeText;
end;
存储动态数组的功能时总是有些问题,源程序如下,请大侠指教!!
-----------------
TSubNodeText = array of string;
function GetAllSubNode(SelNode: TTreeNode): TSubNodeText;
var
ChildNode, TempNode:TTreeNode;
SubNodeText: TSubNodeText;
begin
ChildNode := SelNode.getFirstChild;
while ChildNode <> nildo
//找到第一个子节点了
begin
SetLength(SubNodeText,Length(SubNodeText)+1);
SubNodeText[High(SubNodeText)] := ChildNode.Text;//添加Node的Text到字符数组
TempNode := ChildNode.getFirstChild;
if TempNode <> nil then
//如果还有子节点,则递归
begin
GetAllSubNode(ChildNode);
end;
TempNode := ChildNode;
ChildNode := SelNode.GetNextChild(TempNode);
end;
Result := SubNodeText;
end;