【Delphi初心者】今から始めるDelphi Part01
>>957 program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils, Classes;
const
filename='test.txt';
var
sum: double;
fp: TextFile;
str: string;
begin
sum:=0;
try
try
AssignFile(fp, filename);
Reset(fp);
try
while (not Eof(fp)) do
begin
Readln(fp, str);
sum:=sum+StrToFloatDef(str, 0);
end;
writeln(FloatToStr(sum));
finally
CloseFile(fp);
end;
except
on E: EInOutError do
begin
case (E.ErrorCode) of
2:
begin
writeln(filename);
raise
end;
else
begin
raise Exception.Create('読み込めねー');
970 :
デフォルトの名無しさん:2005/11/12(土) 22:31:38
end;
end;
end;
end;
except
on E: Exception do Writeln(E.Message);
end;
end.