File CLOSE without 0D0A (truncate file)

AsallaiAsallai Member Posts: 142
Hi All,

I've searched this, but I did not find any solution.
So my problem is at the Close a file (Text).
I have to generate a file for a program, but when I close my file, the file.CLOSE procedure is put a 0D0A
of the end of file automatically. :shock:
Can I avoid this? :?: How can I truncate this last 2 bit when I close a file?

Thank you.

Andras

Comments

  • krikikriki Member, Moderator Posts: 9,118
    Try this:
    Just before closing the file, change the mode to binary and close the file.
    I didn't try it out though.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • rthswrthsw Member Posts: 73
    Try this (not tested by me, but should work)

    file.textmode(true);
    file.create('Blubber.txt');
    file.write('DoThis');//This add's 0D0A on the end
    file.write('DoThat');//This add's 0D0A on the end
    file.seek(file.len-2);//This sets the pointer 2 bytes back
    file.trunc;//This cuts the file on the actual pointer
    file.close; //This closes the file w/o adding more Data to it.
  • AsallaiAsallai Member Posts: 142
    rthsw wrote:
    Try this (not tested by me, but should work)

    file.textmode(true);
    file.create('Blubber.txt');
    file.write('DoThis');//This add's 0D0A on the end
    file.write('DoThat');//This add's 0D0A on the end
    file.seek(file.len-2);//This sets the pointer 2 bytes back
    file.trunc;//This cuts the file on the actual pointer
    file.close; //This closes the file w/o adding more Data to it.

    Yes, I tried this method but maybe I did something wrong, because the 0D0A is still there :-o
    But I tried this
    fileData_Out.CLOSE;
    fileData_Out.OPEN(tFullFileName);
    fileData_Out.SEEK(fileData_Out.LEN-2);
    fileData_Out.TRUNC;
    fileData_Out.CLOSE;
    
    It is "stupid" I think, but it is works :-o

    I think rthsw that your code is OK!

    Thank you to all![/b]
Sign In or Register to comment.