Disk write error

We have (are trying to) create a game. To keep easy track of maps and other we create a list file. It's opened when you start and closed when you exit. Many times in between the file needs to be reset and read/write actions are made to find info on data.

It is reset at startup of the program and then once more to add some record. This works fine. The second reset of this file returns a "101 - Disk write error". I have 7 GB free space.
Another thing, after having written an object (pointer referenced) to a file, a simple write('hi'); to the screen also generates this error.

Any help or insults will be appreciated. ^_^

Aessa (until further notice)

Comments

  • : We have (are trying to) create a game. To keep easy track of maps and other we create a list file. It's opened when you start and closed when you exit. Many times in between the file needs to be reset and read/write actions are made to find info on data.
    :
    : It is reset at startup of the program and then once more to add some record. This works fine. The second reset of this file returns a "101 - Disk write error". I have 7 GB free space.
    : Another thing, after having written an object (pointer referenced) to a file, a simple write('hi'); to the screen also generates this error.

    Only thing I can think of for the first problem is that you are not closing the file before calling Reset again? One comment on this...if you have to seek in the file a lot it may be better to create a typed file instead of a text file. You wouldnt have to close and open the file all the time, you could just seek to the position you want.

    And for the second error, I think you'd probably have to post some source code to show exactly how you are writing the object to the file.

  • : : We have (are trying to) create a game. To keep easy track of maps and other we create a list file. It's opened when you start and closed when you exit. Many times in between the file needs to be reset and read/write actions are made to find info on data.
    : :
    : : It is reset at startup of the program and then once more to add some record. This works fine. The second reset of this file returns a "101 - Disk write error". I have 7 GB free space.
    : : Another thing, after having written an object (pointer referenced) to a file, a simple write('hi'); to the screen also generates this error.
    :
    : Only thing I can think of for the first problem is that you are not closing the file before calling Reset again? One comment on this...if you have to seek in the file a lot it may be better to create a typed file instead of a text file. You wouldnt have to close and open the file all the time, you could just seek to the position you want.
    :
    : And for the second error, I think you'd probably have to post some source code to show exactly how you are writing the object to the file.
    :
    ---
    {The List File is a file of string[20] - I do seek a lot as well}
    {I tried seek(filenamehere,0), but same error occurs}
    .
    .
    .
    TArmy = object
    public
    Name : TUsername;
    men : array[1..20] of TFellow;
    Credit : word;
    flagindex:byte;
    function save(overwrite : boolean) : byte;
    function load : boolean;
    procedure zeroallfields;
    end;
    .
    .
    .
    function TArmy.save(overwrite : boolean) : byte;
    var
    s : file;
    r : byte;
    n : string;

    begin
    r:=0;
    if fill(name,20) <> fill('',20) then begin
    n:=addarmy(name);
    if n = 'TMA' then r:=2 else
    if (n = 'AE') then begin
    if overwrite then n:=armtofile(name) else r:=1;
    end;
    if r = 0 then begin
    {$I-}
    assign(s,n);
    rewrite(s);
    blockwrite(s,self,sizeof(self));
    close(s);
    {$I+}
    end;
    end;
    {
    0 - success
    1 - exists
    2 - too many armies
    }
    save:=r;
    end;

    (*In a different unit*)

    procedure SaveArmy;
    begin
    army^.flagindex:=pickaflag;
    army^.name := namearmy;
    army^.credit := maxcash;
    army^.save(true);
    end;

    {Somehwere after this is gotoxy(1,1); write('aaaa'); - error 101}

    ---> Reset closes the file if it is open and then reopens it. It is not reset but close that causes the error, even with IOChecking off.

    Thanks



  • : : : We have (are trying to) create a game. To keep easy track of maps and other we create a list file. It's opened when you start and closed when you exit. Many times in between the file needs to be reset and read/write actions are made to find info on data.
    : : :
    : : : It is reset at startup of the program and then once more to add some record. This works fine. The second reset of this file returns a "101 - Disk write error". I have 7 GB free space.
    : : : Another thing, after having written an object (pointer referenced) to a file, a simple write('hi'); to the screen also generates this error.
    : :
    : : Only thing I can think of for the first problem is that you are not closing the file before calling Reset again? One comment on this...if you have to seek in the file a lot it may be better to create a typed file instead of a text file. You wouldnt have to close and open the file all the time, you could just seek to the position you want.
    : :
    : : And for the second error, I think you'd probably have to post some source code to show exactly how you are writing the object to the file.
    : :
    : ---
    : {The List File is a file of string[20] - I do seek a lot as well}
    : {I tried seek(filenamehere,0), but same error occurs}
    : .
    : .
    : .
    : TArmy = object
    : public
    : Name : TUsername;
    : men : array[1..20] of TFellow;
    : Credit : word;
    : flagindex:byte;
    : function save(overwrite : boolean) : byte;
    : function load : boolean;
    : procedure zeroallfields;
    : end;
    : .
    : .
    : .
    : function TArmy.save(overwrite : boolean) : byte;
    : var
    : s : file;
    : r : byte;
    : n : string;
    :
    : begin
    : r:=0;
    : if fill(name,20) <> fill('',20) then begin
    : n:=addarmy(name);
    : if n = 'TMA' then r:=2 else
    : if (n = 'AE') then begin
    : if overwrite then n:=armtofile(name) else r:=1;
    : end;
    : if r = 0 then begin
    : {$I-}
    : assign(s,n);
    : rewrite(s);
    : blockwrite(s,self,sizeof(self));
    : close(s);
    : {$I+}
    : end;
    : end;
    : {
    : 0 - success
    : 1 - exists
    : 2 - too many armies
    : }
    : save:=r;
    : end;
    :
    : (*In a different unit*)
    :
    : procedure SaveArmy;
    : begin
    : army^.flagindex:=pickaflag;
    : army^.name := namearmy;
    : army^.credit := maxcash;
    : army^.save(true);
    : end;
    :
    : {Somehwere after this is gotoxy(1,1); write('aaaa'); - error 101}
    :
    : ---> Reset closes the file if it is open and then reopens it. It is not reset but close that causes the error, even with IOChecking off.
    :
    : Thanks
    :
    Terribly sorry. I just saw that I don't rewrite with a buffer size. I'll try that.


  • : : : : We have (are trying to) create a game. To keep easy track of maps and other we create a list file. It's opened when you start and closed when you exit. Many times in between the file needs to be reset and read/write actions are made to find info on data.
    : : : :
    : : : : It is reset at startup of the program and then once more to add some record. This works fine. The second reset of this file returns a "101 - Disk write error". I have 7 GB free space.
    : : : : Another thing, after having written an object (pointer referenced) to a file, a simple write('hi'); to the screen also generates this error.
    : : :
    : : : Only thing I can think of for the first problem is that you are not closing the file before calling Reset again? One comment on this...if you have to seek in the file a lot it may be better to create a typed file instead of a text file. You wouldnt have to close and open the file all the time, you could just seek to the position you want.
    : : :
    : : : And for the second error, I think you'd probably have to post some source code to show exactly how you are writing the object to the file.
    : : :
    : : ---
    : : {The List File is a file of string[20] - I do seek a lot as well}
    : : {I tried seek(filenamehere,0), but same error occurs}
    : : .
    : : .
    : : .
    : : TArmy = object
    : : public
    : : Name : TUsername;
    : : men : array[1..20] of TFellow;
    : : Credit : word;
    : : flagindex:byte;
    : : function save(overwrite : boolean) : byte;
    : : function load : boolean;
    : : procedure zeroallfields;
    : : end;
    : : .
    : : .
    : : .
    : : function TArmy.save(overwrite : boolean) : byte;
    : : var
    : : s : file;
    : : r : byte;
    : : n : string;
    : :
    : : begin
    : : r:=0;
    : : if fill(name,20) <> fill('',20) then begin
    : : n:=addarmy(name);
    : : if n = 'TMA' then r:=2 else
    : : if (n = 'AE') then begin
    : : if overwrite then n:=armtofile(name) else r:=1;
    : : end;
    : : if r = 0 then begin
    : : {$I-}
    : : assign(s,n);
    : : rewrite(s);
    : : blockwrite(s,self,sizeof(self));
    : : close(s);
    : : {$I+}
    : : end;
    : : end;
    : : {
    : : 0 - success
    : : 1 - exists
    : : 2 - too many armies
    : : }
    : : save:=r;
    : : end;
    : :
    : : (*In a different unit*)
    : :
    : : procedure SaveArmy;
    : : begin
    : : army^.flagindex:=pickaflag;
    : : army^.name := namearmy;
    : : army^.credit := maxcash;
    : : army^.save(true);
    : : end;
    : :
    : : {Somehwere after this is gotoxy(1,1); write('aaaa'); - error 101}
    : :
    : : ---> Reset closes the file if it is open and then reopens it. It is not reset but close that causes the error, even with IOChecking off.
    : :
    : : Thanks
    : :
    : Terribly sorry. I just saw that I don't rewrite with a buffer size. I'll try that.
    :
    :
    I rewrote with bufsize 1. The filesize (only saw this today) dropped from 34kB to 1kB...it works fine now, sorry for the trouble. ^_^




Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories