全局函数的Result一定要每次都初始化,否则上次的结果会被保持到下一次继续使用

测试半天,原来是因为这个原因。下面例子中,Result:=''必须写,否则其结果会被累计,真是昏倒!!

function MyPaths(tache: IXMLTaskType) : String;
var
    i: integer;
begin
    result := '';
    for i := 0 to task.paths.Count - 1 do
    begin
       if task.paths.path[i].folder<>'' then
            result := Result + task.paths.path[i].folder+#13;
    end;
end;

 

posted @ 2015-10-27 23:27  findumars  Views(404)  Comments(0)    收藏  举报