자세히 소스를 보지는 않았습니다만(금방 훑어보기엔 부담이 좀 있네요), StrToIntDef() 함수에 원인이 잇는 것 같네요. StrToIntDef() 함수의 경우, 첫번째 인자 값이 숫자로 컨버팅이 불가능하면 두번째 인자값을 디폴트 값으로 리턴합니다. 아래 코드에서는 숫자를 못읽을 경우 1을 리턴하게 되어있네요.
그럼...
User 님이 쓰신 글 :
: 아래코딩부분을 보면...
: 파일을 열어보면
: 'This File is Production of Daily & Monthly'
: 위와같이 만 적혀있습니다.
: 그런데 어떻게 파일에서 iNgNo 를 읽어냈는지 이해가 안되네요.
:
: procedure FileReportOpen;
: var
: sTmp : String;
: iNgNo : integer;
: TDataFile : TextFile;
: begin
: if not FileExists(sSaveFileName) then
: begin
: AssignFile(TDataFile, sSaveFileName);
: ReWrite(TDataFile);
: WriteLn(TDataFile, 'This File is Production of Daily & Monthly' );
: CloseFile(TDataFile);
: end;
:
: AssignFile(TDataFile, sSaveFileName);
: Reset(TDataFile);
:
: ReadLn(TDataFile, sTmp);
:
: iMakeTotal := 0;
: iMakeNg := 0;
:
: while not Eof(TDataFile) do
: begin
: Inc(iMakeTotal);
:
: ReadLn(TDataFile, sTmp);
: iNgNo := StrToIntDef(sTmp,1);
:
: if iNgNo <> 0 then Inc(iMakeNg);
: end;
:
: iMakeOK := iMakeTotal - iMakeNg;
:
: if (iMakeOK <> 0) and (iMakeTotal <> 0) then rMakePersent := (iMakeOK / iMakeTotal) * 100
: else rMakePersent := 0;
:
: CloseFile(TDataFile);
: end;
:
: procedure FileReportSave(iTestReturn : Integer);
: var
: TDataFile : TextFile;
: begin
: AssignFile(TDataFile, sSaveFileName);
: Append(TDataFile);
:
: WriteLn(TDataFile, IntToStr(iTestReturn));
:
: CloseFile(TDataFile);
:
: FileReportOpen;
: end;
|