在李维的Delphi.5.X.ADO.MTS.COM+高级程序设计篇中第三章104页上有这么一段:
function TForm1.BlobContentToString(const FileName: string): string;
begin
with TFileStream.Create(FileName,fmOpenRead) do
try
SetLength(Result,Size);
Read(Pointer(Result)^,Size);
finally
end;
end;
请帮我解释下其中的Size变量在哪声明的呀,那个Result变量是不是每个函数公用它,它总是返回上一次调用过的函数返回值的呀!!
谢了!!
function TForm1.BlobContentToString(const FileName: string): string;
begin
with TFileStream.Create(FileName,fmOpenRead) do
try
SetLength(Result,Size);
Read(Pointer(Result)^,Size);
finally
end;
end;
请帮我解释下其中的Size变量在哪声明的呀,那个Result变量是不是每个函数公用它,它总是返回上一次调用过的函数返回值的呀!!
谢了!!
Result//每个函数都自己带有,不用定义
Size其实是:TFileStream.Create(FileName,fmOpenRead).Size,也就是创建的那个文件流的Size
Delphi syntax:procedure SetLength(var S; NewLength: Integer);DescriptionS is a Delphi string or dynamic-array variable.NewLength is the new number of characters or elements in S.