Howdy, Stranger!

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

Categories

weird error writing a textfile

I have a weird error that happens when the program's writeln procedures are being executed. It is an access violation error.

When the program crashes in Delphi, I don't get a line number to go from, it just gives me an assembly window.

The textfile that was being written when the error happens, sometimes has constant strings that have been truncated.

For example, there might be a procedure like "writeln(tf,'Frames: '+inttostr(maxframes));" and the last line of tf might be "fram".

The program sometimes works without any problems but not always.

If anyone would like to give the problem a try, [b]please[/b] contact me and I'll email the Delphi 4 source files and some sample input files.

Even an effort to solve this problem would be greatly appreciated.

Comments

  • zibadianzibadian Member Posts: 6,349
    : I have a weird error that happens when the program's writeln procedures are being executed. It is an access violation error.
    :
    : When the program crashes in Delphi, I don't get a line number to go from, it just gives me an assembly window.
    :
    : The textfile that was being written when the error happens, sometimes has constant strings that have been truncated.
    :
    : For example, there might be a procedure like "writeln(tf,'Frames: '+inttostr(maxframes));" and the last line of tf might be "fram".
    :
    : The program sometimes works without any problems but not always.
    :
    : If anyone would like to give the problem a try, [b]please[/b] contact me and I'll email the Delphi 4 source files and some sample input files.
    :
    : Even an effort to solve this problem would be greatly appreciated.
    :
    :
    The example you gave here can also be written like this:
    [code]
    writeln(tf, 'Frames: ', MaxFrames);
    [/code]
    As for your problem, it seems to me that the tf variable hasn't been assigned to a filename, or you are trying to write an invalid variable, such as a pointer or an object. You could try the Search|Find Error to find the exact line of the problem. If that doesn't help you could always trace through your save routine.
  • Josh CodeJosh Code Member Posts: 675
    : The example you gave here can also be written like this:
    : [code]
    : writeln(tf, 'Frames: ', MaxFrames);
    : [/code]
    : As for your problem, it seems to me that the tf variable hasn't been assigned to a filename, or you are trying to write an invalid variable, such as a pointer or an object. You could try the Search|Find Error to find the exact line of the problem. If that doesn't help you could always trace through your save routine.
    :

    Thanks for the advise but the variable is not a pointer and the tf is properly assigned.

    The error must happen when the writeln procedures are being executed because I can see it in the file that is being written after the program crashes. The lines are either truncated or have symbol characters added to the end of the line.

    Here is the code that is being executed when the error usually happens:
    [code]
    WriteLn(TXTOutputF,[blue]'File: '[/blue]+fn);
    WriteLn(TXTOutputF,[blue]'Width: '[/blue]+inttostr(bit1.width));
    WriteLn(TXTOutputF,[blue]'Height: '[/blue]+inttostr(Bit1.height));
    WriteLn(TXTOutputF,[blue]'Offset in pixel data: '[/blue]+inttostr(Bnum));
    WriteLn(TXTOutputF,[blue]'Total Size: '[/blue]+inttostr(bit1.height*Bit1.Width [b]div[/b] 2));
    WriteLn(TXTOutputF,[blue]'Frames: '[/blue]+inttostr(frames));
    WriteLn(TXTOutputF,[blue]'Frame Width: '[/blue]+inttostr(hw*2));
    WriteLn(TXTOutputF,[blue]'Frame Size: '[/blue]+inttostr(bit1.height*hw));
    [/code]


    here is a section near the end of the file being written:
    ----------------------
    File: Marine_stop_Back.bmp
    Width: 24
    Height: 16
    Offset in pixel data: 1344
    Total Size: 192
    Frames: 3
    Frame Width: 8
    Frame Size: 64
    Palette Number: 0
    ----------------------
    File: Guard_Walking_Forward.bmp
    Width: 24
    Height: 16
    Offset in pi


    That last line was copied correctly. The last character is in the file "i". Sometimes the error happens in different places. Keep in mind that the line of code writing that line is:
    [code]
    WriteLn(TXTOutputF,[blue]'Offset in pixel data: '[/blue]+inttostr(Bnum));
    [/code]
    It should have atleast finished the [blue]'Offset in pixel data: '[/blue].
  • Josh CodeJosh Code Member Posts: 675
    Someone figured out what was wrong.

    If you're curious, it actually had little to do with the writeln procedures. It was a problem with pointers that I was using to access a bitmap's pixel information. I looped through too much information. Somehow the problem doesn't automatically cause an error every time.

    I also changed a parameter for a procedure from cardinal to integer.

    Thanks for the people that helped.
  • Justin BibJustin Bib USAMember Posts: 0

    __ [ http://forcoder.org ] free ebooks and video tutorials about ( Scratch, MATLAB, Python, C#, Ruby, Java, C, JavaScript, Perl, Visual Basic .NET, R, PHP, Delphi, Swift, Objective-C, C++, Assembly, Go, Visual Basic, PL/SQL Julia, F#, ML, D, Erlang, Transact-SQL, Dart, FoxPro, Clojure, Crystal, Prolog, VBScript, Lisp, Hack, Awk, COBOL, Alice, Logo, Fortran, ABAP, Bash, Kotlin, Scheme, Lua, Scala, SAS, Ada, Rust, Apex, LabVIEW ) ______

Sign In or Register to comment.