delphi文件类型转换读文件函数错误请大佬帮帮忙

weixin_40024154 2018-05-04 04:35:41
function TResultFile.GetResultRec(NFileName:string; var NValue: TResultRec_A) : boolean;
var
tmpStream:TStream;
i,StepCount,tmpLength:Integer;
begin
Result:=False;
SetLength( NValue.ResultData,0);
if not FileExists(NFileName) then
Exit;
tmpStream:=TFileStream.Create(NFileName,fmOpenRead);
try
tmpLength:=tmpStream.Size;
with tmpStream,NValue do
try
Position:=0;
Read(StartDateTime,SizeOf(StartDateTime));
Read(FinishDateTime,SizeOf(FinishDateTime));
Read(StartBTime,SizeOf(StartBTime));
Read(FinishBTime,SizeOf(FinishBTime));
Read(DataLength,SizeOf(DataLength));
SetLength(GraphData,DataLength);
for i:=0 to DataLength -1 do
Read(ResultData[i],SizeOf(ResultData[i]));
Result:=True;
except
FillChar(NValue,SizeOf(AValue),0);
end;
finally
tmpStream.Free;
end;
end;


[错误] Unit1.pas(55): Function needs result type
[错误] Unit1.pas(55): ';' expected but ')' found
[错误] Unit1.pas(55): ',' or ':' expected but ';' found
[错误] Unit1.pas(56): Type expected but 'VAR' found
[错误] Unit1.pas(62): Undeclared identifier: 'AFileName'
[错误] Unit1.pas(64): There is no overloaded version of 'Create' that can be called with these arguments
[错误] Unit1.pas(79): Undeclared identifier: 'StartDateTime'
[错误] Unit1.pas(80): Undeclared identifier: 'FinishDateTime'
...全文
2063 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
LETOsoft 2018-05-16
  • 打赏
  • 举报
回复
代码不全,不知道你上面怎么声明,还有什么代码。 单纯把这个函数摘出来,乱编了一个TResultRec_A,编译是不成问题的。 type TResultRec_A = record ResultData: string; StartDateTime: PChar; FinishDateTime: PChar; StartBTime: PChar; FinishBTime: PChar; DataLength: Integer; GraphData: string; end; var AValue: TResultRec_A; function GetResultRec(NFileName: string; var NValue: TResultRec_A): boolean; var tmpStream: TStream; i, StepCount, tmpLength: Integer; begin Result := False; SetLength(NValue.ResultData, 0); if not FileExists(NFileName) then Exit; tmpStream := TFileStream.Create(NFileName, fmOpenRead); try tmpLength := tmpStream.Size; with tmpStream, NValue do try Position := 0; Read(StartDateTime, SizeOf(StartDateTime)); Read(FinishDateTime, SizeOf(FinishDateTime)); Read(StartBTime, SizeOf(StartBTime)); Read(FinishBTime, SizeOf(FinishBTime)); Read(DataLength, SizeOf(DataLength)); SetLength(GraphData, DataLength); for i := 0 to DataLength - 1 do Read(ResultData[i], SizeOf(ResultData[i])); Result := True; except FillChar(NValue, SizeOf(AValue), 0); end; finally tmpStream.Free; end; end;

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧