[fpc-pascal] FreePascal Windows - Force files to write to disk

Klaus Hartnegg hartnegg at gmx.de
Thu Feb 23 12:32:34 CET 2017


Am 21.02.2017 um 22:12 schrieb James Richters:
>  Assign(BitFile,'BitSave.pax');
    {$I-}
>  ReWrite(BitFile);
    if ioresult <> 0 then
       writeln ('error opening pax file');
>  WriteLn(BitFile,XADJ:1:8);
>  WriteLn(BitFile,YADJ:1:8);
>  WriteLn(BitFile,ZADJ:1:8);
>  WriteLn(BitFile,WADJ:1:8);
>  WriteLn(BitFile,AADJ:1:8);
>  WriteLn(BitFile,TADJ:1:8);
>  WriteLn(BitFile,VADJ:1:8);
>  WriteLn(BitFile,UADJ:1:8);
>  WriteLn(BitFile,CurrentTool);
>  WriteLn(Bitfile,P_Value[4]);
    writeln (bitfile, 'EOF');
    if ioresult <> 0 then
       writeln ('error writing pax file');
>  Close(BitFile);
    if ioresult <> 0 then
       writeln ('error closing pax file');
    {$I+}

This writes something at the end of the file that does not come from a 
variable. Next time the error happens, you can check if that is present. 
Then your variables were overwritten in memory. Also it checks for 
errors. And I would disable antivirus or at least tell it to not scan 
this file.



More information about the fpc-pascal mailing list